def dir_tree_find(tree, kind):
 nodes = []
 if isinstance(tree, list):
  for t in tree:
   nodes += dir_tree_find(t, kind)
 else:
  if (tree['block'] == kind):
   nodes.append(tree)
  for child in tree['children']:
   nodes += dir_tree_find(child, kind)
 return nodes

def dir_tree_find ( tree , kind ) : nodes = [ ] if isinstance ( tree , list ) : for t in tree : nodes += dir_tree_find ( t , kind ) else : if ( tree [ 'block' ] == kind ) : nodes . append ( tree ) for child in tree [ 'children' ] : nodes += dir_tree_find ( child , kind ) return nodes
find nodes of the given kind from a directory tree structure .