#NEWLINE# def replace( self , newtree ) : #NEWLINE# #INDENT# if ( not isinstance ( newtree , ( ElementNode , Text , Comment ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Must replace with another ElementNode' ) #NEWLINE# #UNINDENT# if self . _parent : #NEWLINE# #INDENT# p = self . _parent #NEWLINE# i = self . _parent . index ( self ) #NEWLINE# del self . _parent [ i ] #NEWLINE# self . _parent = None #NEWLINE# p . insert ( i , newtree ) #NEWLINE# #UNINDENT# return self