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