def select(umf, include=None, exclude=None):
    """
    Given a UM file object and some filtering dictionaries, return a list of
    qualifying fields.

    Args:
        * umf:
            A :class:`mule.UMFile` object.

    Kwargs:
        * include:
            A dictionary defining lookup header combinations which should be
            included in the output; keys are the lookup names as defined by
            Mule, values are lists of the values to match.
        * exclude:
            A dictionary defining lookup header combinations which should be
            excluded from the output; keys are the lookup names as defined by
            Mule, values are lists of the values to exclude.

    """
    fields_out = [f for f in umf.fields]
    if include is not None:
        for field in list(fields_out):
            # Process includes first... the field has to meet all of the
            # criteria not to be removed, so as soon as it fails one criteria
            # remove it
            for header, vals in include.items():
                if getattr(field, header, None) not in vals:
                    fields_out.remove(field)
                    break

    if exclude is not None:
        for field in list(fields_out):
            # After processing includes, process excludes on the result,
            # since the two are to be "and"ed together anyway.  This time
            # however a field must fail to satisfy all of the conditions
            check = []
            for header, vals in exclude.items():
                if getattr(field, header, None) in vals:
                    check.append(True)
            if len(check) > 0 and all(check):
                fields_out.remove(field)

    return fields_out