import inspect


def is_instance_or_subclass(thing, klass):
    """
        Check if a thing is an instance or subclass of a given class (or set of classes)
    """
    return isinstance(thing, klass) or (inspect.isclass(thing) and issubclass(thing, klass))