def get_subclasses(cls, _subclasses_yielded=None):
if _subclasses_yielded is None:<EOL><INDENT>_subclasses_yielded = set()<EOL><DEDENT>if not hasattr(cls, '<STR_LIT>'):<EOL><INDENT>raise TypeError('<STR_LIT>' % cls.__name__)<EOL><DEDENT>for subclass in cls.__subclasses__():<EOL><INDENT>if subclass in _subclasses_yielded:<EOL><INDENT>continue<EOL><DEDENT>yield subclass<EOL>_subclasses_yielded.add(subclass)<EOL>for subclass_subclass in get_subclasses(subclass, _subclasses_yielded):<EOL><INDENT>yield subclass_subclass<EOL><DEDENT><DEDENT>
Generator recursively yielding all subclasses of the passed class (in
depth-first order).

Parameters
----------
cls : type
    Class to find all subclasses of.
_subclasses_yielded : set
    Private parameter intended to be passed only by recursive invocations of
    this function, containing all previously yielded classes.