def getclasstree(classes, unique=0):
 children = {}
 roots = []
 for c in classes:
  if c.__bases__:
   for parent in c.__bases__:
    if (not (parent in children)):
     children[parent] = []
    if (c not in children[parent]):
     children[parent].append(c)
    if (unique and (parent in classes)):
     break
  elif (c not in roots):
   roots.append(c)
 for parent in children:
  if (parent not in classes):
   roots.append(parent)
 return walktree(roots, children, None)

def getclasstree ( classes , unique = 0 ) : children = { } roots = [ ] for c in classes : if c . __bases__ : for parent in c . __bases__ : if ( not ( parent in children ) ) : children [ parent ] = [ ] if ( c not in children [ parent ] ) : children [ parent ] . append ( c ) if ( unique and ( parent in classes ) ) : break elif ( c not in roots ) : roots . append ( c ) for parent in children : if ( parent not in classes ) : roots . append ( parent ) return walktree ( roots , children , None )
arrange the given list of classes into a hierarchy of nested lists .