#NEWLINE# def testTraverseCompressing( self ) : #NEWLINE# #INDENT# t = pygtrie . CharTrie ( ) #NEWLINE# t . update ( { #NEWLINE# #INDENT# 'aaa' : 1 , #NEWLINE# 'aab' : 2 , #NEWLINE# 'aac' : 3 , #NEWLINE# 'bb' : 4 , #NEWLINE# #UNINDENT# } ) #NEWLINE# def make( path_conv , path , children , value = self . _SENTINEL ) : #NEWLINE# #INDENT# children = list ( children ) #NEWLINE# if ( ( value is self . _SENTINEL ) and ( len ( children ) == 1 ) ) : #NEWLINE# #INDENT# return children [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . _TestNode ( path_conv ( path ) , children , value ) #NEWLINE# #UNINDENT# #UNINDENT# r = t . traverse ( make ) #NEWLINE# self . assertNode ( r , '' , 2 ) #NEWLINE# aa_node = self . assertNode ( r . children [ 0 ] , 'aa' , 3 ) #NEWLINE# self . assertNode ( aa_node . children [ 0 ] , 'aaa' , 0 , 1 ) #NEWLINE# self . assertNode ( aa_node . children [ 1 ] , 'aab' , 0 , 2 ) #NEWLINE# self . assertNode ( aa_node . children [ 2 ] , 'aac' , 0 , 3 ) #NEWLINE# self . assertNode ( r . children [ 1 ] , 'bb' , 0 , 4 )