def _is_valid_kwarg(provided: dict, available: dict):
    """
    Helper function to check if a user provided dictionary has the correct arguments,
    compared to a dictionary with the actual available arguments.

    Updates, if no difference found, the dictionary 'available'.

    Parameters
    ----------
    provided : `dict`
        The user defined dictionary of optional additional arguments.
    available : `dict`
        The available optional additional arguments possible.

    :raises KeyError:
        invalid additional keyword argument supplied
    """

    diff = provided.keys() - available.keys()
    if diff:  # if there are differences
        msg = "invalid optional keyword argument passed: {}. Available arguments: {}".format(diff, list(available.keys()))
        raise KeyError(msg)
    available.update(provided)
    return available