def _resolve_node_deps(self, node: TaskExecutionNode):
        """
        Build a DAG of tasks by depth-first traversal of the dependency tree starting
        from the sink node.
        """
        for key, task in node.task.iter_upstream_tasks(self._context):
            node.direct_dependencies.add(task.invocation)

            if task.invocation in node.path_dependants:
                raise CyclicDependencyError(
                    f"Encountered cyclic task dependency with task: {task.name!r}"
                )

            # a non empty key indicates output is captured
            capture_stdout = bool(key)

            # Check if a node already exists for this task
            if capture_stdout:
                if task.invocation in self.captured_tasks:
                    # reuse instance of task with captured output
                    self.captured_tasks[task.invocation].direct_dependants.append(node)
                    continue
            elif task.invocation in self.uncaptured_tasks:
                # reuse instance of task with uncaptured output
                self.uncaptured_tasks[task.invocation].direct_dependants.append(node)
                continue

            # This task has not been encountered before via another path
            new_node = TaskExecutionNode(
                task, [node], node.path_dependants, capture_stdout
            )

            # Keep track of this task/node so it can be found by other dependants
            if capture_stdout:
                self.captured_tasks[task.invocation] = new_node
            else:
                self.uncaptured_tasks[task.invocation] = new_node

            if new_node.is_source():
                # Track this node as having no dependencies
                self.sources.append(new_node)
            else:
                # Recurse immediately for DFS
                self._resolve_node_deps(new_node)

        Build a DAG of tasks by depth-first traversal of the dependency tree starting
        from the sink node.
        
poethepoet/task/graph.py