#NEWLINE# def replaceChild( self , old_node , new_node ) : #NEWLINE# #INDENT# if ( ( new_node is not None ) and ( not isinstance ( new_node , NodeBase ) ) ) : #NEWLINE# #INDENT# raise AssertionError ( 'Cannot replace with' , new_node , 'old' , old_node , 'in' , self ) #NEWLINE# #UNINDENT# for ( key , value ) in self . child_values . items ( ) : #NEWLINE# #INDENT# if ( value is None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type ( value ) is tuple ) : #NEWLINE# #INDENT# if ( old_node in value ) : #NEWLINE# #INDENT# if ( old_node is not None ) : #NEWLINE# #INDENT# self . setChild ( key , tuple ( ( ( val if ( val is not old_node ) else new_node ) for val in value ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . setChild ( key , tuple ( ( val for val in value if ( val is not old_node ) ) ) ) #NEWLINE# #UNINDENT# return key #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( value , NodeBase ) : #NEWLINE# #INDENT# if ( old_node is value ) : #NEWLINE# #INDENT# self . setChild ( key , new_node ) #NEWLINE# return key #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert False , ( key , value , value . __class__ ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# raise AssertionError ( "Didn't find child" , old_node , 'in' , self )