#NEWLINE# def _merge_common_prefixes( self , info , branches ) : #NEWLINE# #INDENT# prefixed = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# order = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# new_branches = [ ] #NEWLINE# for b in branches : #NEWLINE# #INDENT# if self . _is_simple_character ( b ) : #NEWLINE# #INDENT# assert isinstance ( b , Character ) #NEWLINE# prefixed . setdefault ( b . value , [ ] ) . append ( [ b ] ) #NEWLINE# order . setdefault ( b . value , len ( order ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( b , Sequence ) and b . items and self . _is_simple_character ( b . items [ 0 ] ) ) : #NEWLINE# #INDENT# item = b . items [ 0 ] #NEWLINE# assert isinstance ( item , Character ) #NEWLINE# prefixed . setdefault ( item . value , [ ] ) . append ( b . items ) #NEWLINE# order . setdefault ( item . value , len ( order ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _flush_char_prefix ( info , prefixed , order , new_branches ) #NEWLINE# new_branches . append ( branches ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _flush_char_prefix ( info , prefixed , order , new_branches ) #NEWLINE# return new_branches