from typing import Type


def _all_subclasses(cls: Type):
    """Get all explicit and implicit subclasses of a type."""
    return set(cls.__subclasses__()).union([s for c in cls.__subclasses__() for s in _all_subclasses(c)])