def _insert_action(self, node):
        task = self
        if (node.end_message and node.start_message
            and (len(node.children) ==
                 node.end_message.task_level.level[-1] - 2)):
            # Possibly this action is complete, make sure all sub-actions
            # are complete:
            completed = True
            for child in node.children:
                if (isinstance(child, WrittenAction) and
                        child.task_level not in self._completed):
                    completed = False
                    break
            if completed:
                task = task.transform(["_completed"],
                                      lambda s: s.add(node.task_level))
        task = task.transform(["_nodes", node.task_level], node)
        return task._ensure_node_parents(node)
Add a L{WrittenAction} to the tree.
dataset/ETHPy150Open ClusterHQ/eliot/eliot/_parse.py/Task._insert_action