<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_task_var(self, key, default=None):
 """ Fetch the value of a task variable related to connection configuration, or, if delegate_to is active, fetch the same variable via HostVars for the delegated-to machine. When running with delegate_to, Ansible tasks have variables associated with the original machine, not the delegated-to machine, therefore it does not make sense to extract connection-related configuration for the delegated-to machine from them. """

        if self._task_vars:
            if self.delegate_to_hostname is None:
                if key in self._task_vars:
                    return self._task_vars[key]
            else:
                delegated_vars = self._task_vars['ansible_delegated_vars']
                if self.delegate_to_hostname in delegated_vars:
                    task_vars = delegated_vars[self.delegate_to_hostname]
                    if key in task_vars:
                        return task_vars[key]

        return default