def _call_if_not_instance_of(key, cls, *args, **kwargs):
    """ If key is not an instance of cls, call it with *args and **kwargs, otherwise just return it. """
    return key(*args, **kwargs) if not isinstance(key, cls) else key