#NEWLINE# def reverse( self , tree ) : #NEWLINE# #INDENT# self . visit ( tree ) #NEWLINE# current = new_root = self . stack . pop ( ) #NEWLINE# name = [ current . _name ] #NEWLINE# while self . stack : #NEWLINE# #INDENT# next_ = self . stack . pop ( ) #NEWLINE# current . value = next_ #NEWLINE# current = next_ #NEWLINE# name . append ( name . _name ) #NEWLINE# #UNINDENT# new_root . _name = '.' . join ( name ) . replace ( '.[' , '[' ) #NEWLINE# current . value = None #NEWLINE# return new_root