Returns a dictionary representation of a provided model type

def _get_k8s_model_dict(model_type, model):
    """
    Returns a dictionary representation of a provided model type
    """
    model = copy.deepcopy(model)

    if isinstance(model, model_type):
        return model.to_dict()
    elif isinstance(model, dict):
        return _map_dict_keys_to_model_attributes(model_type, model)
    else:
        raise AttributeError("Expected object of type '{}' (or 'dict') but got '{}'.".format(model_type.__name__, type(model).__name__))