def walkQObjectTree(obj, counts=None, verbose=False, depth=0):
 if verbose:
  print((('  ' * depth) + typeStr(obj)))
 report = False
 if (counts is None):
  counts = {}
  report = True
 typ = str(type(obj))
 try:
  counts[typ] += 1
 except KeyError:
  counts[typ] = 1
 for child in obj.children():
  walkQObjectTree(child, counts, verbose, (depth + 1))
 return counts

def walkQObjectTree ( obj , counts = None , verbose = False , depth = 0 ) : if verbose : print ( ( ( '  ' * depth ) + typeStr ( obj ) ) ) report = False if ( counts is None ) : counts = { } report = True typ = str ( type ( obj ) ) try : counts [ typ ] += 1 except KeyError : counts [ typ ] = 1 for child in obj . children ( ) : walkQObjectTree ( child , counts , verbose , ( depth + 1 ) ) return counts
walk through a tree of qobjects .