def walk_class_hierarchy(clazz, encountered=None):
 if (not encountered):
  encountered = []
 for subclass in clazz.__subclasses__():
  if (subclass not in encountered):
   encountered.append(subclass)
   for subsubclass in walk_class_hierarchy(subclass, encountered):
    (yield subsubclass)
   (yield subclass)

def walk_class_hierarchy ( clazz , encountered = None ) : if ( not encountered ) : encountered = [ ] for subclass in clazz . __subclasses__ ( ) : if ( subclass not in encountered ) : encountered . append ( subclass ) for subsubclass in walk_class_hierarchy ( subclass , encountered ) : ( yield subsubclass ) ( yield subclass )
walk class hierarchy .