def optional_converter(kwargs_dict, convert_to_cls):
    """Instantiate a class instances from dict."""
    if kwargs_dict is not None and not isinstance(kwargs_dict, convert_to_cls):
        return convert_to_cls(**kwargs_dict)
    return kwargs_dict
