from functools import reduce
def search_disj(factors):
    sets = (indices[field][key] for field, key in factors)
return (data[index] for index in reduce(set.union, sets))
Comparing dictionaries based on a combination of keys