def require_dict_kwargs(kwargs, msg=None):
    """ Ensure arguments passed kwargs are either None or a dict.
        If arguments are neither a dict nor None a RuntimeError
        is thrown
    Args:
        kwargs (object): possible dict or None
        msg (None, optional): Error msg
    Returns:
        dict: kwargs dict
    Raises:
        RuntimeError: if the passed value is neither a dict nor None
            this error is raised
    """
    if kwargs is None:
        return dict()
    elif isinstance(kwargs, dict):
        return kwargs
    else:
        if msg is None:
            raise RuntimeError(
                "value passed as keyword argument dict is neither None nor a dict")
        else:
            raise RuntimeError("%s" % str(msg))