#NEWLINE# def treepos( self , tree ) : #NEWLINE# #INDENT# "\n        Convert this pointer to a standard 'tree position' pointer,\n        given that it points to the given tree.\n        " #NEWLINE# if ( tree is None ) : #NEWLINE# #INDENT# raise ValueError ( 'Parse tree not avaialable' ) #NEWLINE# #UNINDENT# stack = [ tree ] #NEWLINE# treepos = [ ] #NEWLINE# wordnum = 0 #NEWLINE# while True : #NEWLINE# #INDENT# if isinstance ( stack [ ( - 1 ) ] , Tree ) : #NEWLINE# #INDENT# if ( len ( treepos ) < len ( stack ) ) : #NEWLINE# #INDENT# treepos . append ( 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# treepos [ ( - 1 ) ] += 1 #NEWLINE# #UNINDENT# if ( wordnum [ ( - 1 ) ] < len ( stack [ ( - 1 ) ] ) ) : #NEWLINE# #INDENT# stack . append ( stack [ ( - 1 ) ] [ treepos [ ( - 1 ) ] ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stack . pop ( ) #NEWLINE# treepos . pop ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( wordnum == self . wordnum ) : #NEWLINE# #INDENT# return tuple ( treepos [ : ( ( len ( treepos ) - self . height ) - 1 ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# wordnum += 1 #NEWLINE# stack . pop ( )