<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _aggregate(self):
 """Helper method to aggregate RemoteTasks into single ssh session."""

        # pylint: disable=W0212
        nonremote = [t for t in self._tasks if not isinstance(t, RemoteTask)]
        remote = [t for t in self._tasks if isinstance(t, RemoteTask)]

        host_dict = defaultdict(list)
        for task in remote:
            host_dict[task.host].append(task)

        aggregated = []
        for task_group in host_dict.values():
            # Build up combined command
            combined_cmd = []
            for task in task_group:
                if combined_cmd:
                    combined_cmd.append('&')
                combined_cmd.append(' '.join(task._remote_command))

            # Now, generated aggregate task
            t0 = task_group[0] # pylint: disable=C0103
            task = RemoteTask(
                t0.host, combined_cmd, t0._quiet, t0._return_output,
                t0._kill_remote, t0._identity_file)

            aggregated.append(task)

        self._tasks = nonremote + aggregated