def _get_subclasses(klass):
    """ Adapted from http://stackoverflow.com/a/29106313/1938621. """
    result = [klass]
    classes_to_inspect = [klass]
    while classes_to_inspect:
        class_to_inspect = classes_to_inspect.pop()
        for subclass in class_to_inspect.__subclasses__():
            if subclass not in result:
                result.append(subclass)
                classes_to_inspect.append(subclass)
    return result
