import functools


def union_of_non_none_sets(sets):
    """
    Helper function, takes a list of [set or None] and returns the union of all
    non-None elements.
    """
    return functools.reduce(lambda x, y: x.union(y), filter(lambda z: z is not\
                                                            None, sets), set())