def subclasses(cls, and_self=False):
    """
    Return all subclasses for a given class.
    :param cls: A class object.
    :param and_self: Include the given class in the resulting list.
    """
    base = [cls] if and_self else []
    sub = cls.__subclasses__()
    return base + sub + [g for s in sub for g in subclasses(s, False)]