code: def _ensure_node_parents(self, child):
          
          task_level = child.task_level
          if task_level.parent() is None:
              return self
  
          parent = self._nodes.get(task_level.parent())
          if parent is None:
              parent = WrittenAction(
                  task_level=task_level.parent(), task_uuid=child.task_uuid)
          parent = parent._add_child(child)
          return self._insert_action(parent)
docs: Ensure the node (WrittenAction/WrittenMessage) is referenced by parent
          nodes.
  
          Parent actions will be created as necessary.
  
          @param child: A L{WrittenMessage} or L{WrittenAction} which is
              being added to the tree.
  
          @return: Updated L{Task}.