#NEWLINE# def find_path_in_tree( data , path_tokens ) : #NEWLINE# #INDENT# for i in range ( 0 , len ( path_tokens ) ) : #NEWLINE# #INDENT# if ( isinstance ( data , dict ) or isinstance ( data , list ) ) : #NEWLINE# #INDENT# if ( path_tokens [ i ] in data ) : #NEWLINE# #INDENT# data = data [ path_tokens [ i ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise KeyError ( '/' . join ( path_tokens [ 0 : i ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( i != ( len ( path_tokens ) - 1 ) ) : #NEWLINE# #INDENT# raise KeyError ( '/' . join ( path_tokens [ 0 : i ] ) ) #NEWLINE# #UNINDENT# data = data [ path_tokens [ i ] ] #NEWLINE# #UNINDENT# #UNINDENT# return data