def all_sub(cl, been_there=None):
    """
    return all subclasses of the given class
    """
    if been_there is None:
        been_there = set()
    sub = set(cl.__subclasses__()) | been_there
    new_subs = set(cl.__subclasses__()) - been_there
    for one_sub in new_subs:
        sub |= all_sub(one_sub, sub)
    return sub