def mergeGroupDicts(ListGDict):
    """ this routine takes a list of group dicts
    each element containing a dict of matching images
    returned by a condition modules.

    So if for example the date module returned:
    GL1 = { 1:{1,2,3}, 2:{2,3,6}, 5:{5,6} }
    and the hash module returned:
    GL2 = { 2:{2,3,4}, 5:{5,6}, 6:{6,7} }
    the ListGDict will be [G1, G2]

    This function should return the union of each by element:
    GL = { 1:{1,2,3}, 2:{2,3,4,6}, 5:{5,6}, 6:{6,7} }
    """
    GDict = {}
    for d in ListGDict:
        for m, g in d.items():
            previous = GDict[m] if m in GDict else set()
            GDict[m] = previous | g
    return GDict
