def get_all_subclasses(cls):
 subclasses = cls.__subclasses__()
 to_visit = list(subclasses)
 while to_visit:
  for sc in to_visit:
   to_visit.remove(sc)
   for ssc in sc.__subclasses__():
    subclasses.append(ssc)
    to_visit.append(ssc)
 return subclasses

def get_all_subclasses ( cls ) : subclasses = cls . __subclasses__ ( ) to_visit = list ( subclasses ) while to_visit : for sc in to_visit : to_visit . remove ( sc ) for ssc in sc . __subclasses__ ( ) : subclasses . append ( ssc ) to_visit . append ( ssc ) return subclasses
used by modules like hardware or network fact classes to retrieve all subclasses of a given class .