def preprocess_arguments(argsets, converters):
    """convert and collect arguments in order of priority

    Parameters
    ----------
    argsets : [{argname: argval}]
        a list of argument sets, each with lower levels of priority
    converters : {argname: function}
        conversion functions for each argument

    Returns
    -------
    result : {argname: argval}
        processed arguments
    """
    result = {}
    for argset in argsets:
        for argname, argval in argset.items():
            if not argname in converters:
                raise ValueError('Unrecognized argument: {0}'.format(argname))
            if argname not in result and argval is not None:
                argval = converters[argname](argval)
                result[argname] = argval
    if not len(converters.keys()) == len(result.keys()):
        missing = set(converters.keys()) - set(result.keys())
        s = 'The following arguments are missing: {0}'.format(list(missing))
        raise ValueError(s)
    return result
