#NEWLINE# def subtree_query( self , root , query_parts ) : #NEWLINE# #INDENT# if query_parts : #NEWLINE# #INDENT# my_query = query_parts [ 0 ] #NEWLINE# if is_pattern ( my_query ) : #NEWLINE# #INDENT# matches = [ root [ 1 ] [ node ] for node in match_entries ( root [ 1 ] , my_query ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( my_query in root [ 1 ] ) : #NEWLINE# #INDENT# matches = [ root [ 1 ] [ my_query ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# matches = [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# matches = root [ 1 ] . values ( ) #NEWLINE# #UNINDENT# for child_node in matches : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# 'path' : child_node [ 0 ] , #NEWLINE# 'is_leaf' : bool ( child_node [ 0 ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( result [ 'path' ] is not None ) and ( not result [ 'is_leaf' ] ) ) : #NEWLINE# #INDENT# result [ 'path' ] += '.' #NEWLINE# #UNINDENT# ( yield result ) #NEWLINE# if query_parts : #NEWLINE# #INDENT# for result in self . subtree_query ( child_node , query_parts [ 1 : ] ) : #NEWLINE# #INDENT# ( yield result )