'Negation of a query dict
@param query: the query dict {component_alias: filter_query}'

def _not(self, query):

    if (query is None):
        return None
    if (len(query) == 1):
        (alias, sub) = query.items()[0]
        if ((sub.op == S3ResourceQuery.OR) and (alias is None)):
            l = sub.left
            r = sub.right
            lalias = self._alias(sub.left.left)
            ralias = self._alias(sub.right.left)
            if (lalias == ralias):
                return {alias: (~ sub)}
            else:
                return {lalias: (~ sub.left), ralias: (~ sub.right)}
        elif (sub.op == S3ResourceQuery.NOT):
            return {alias: sub.left}
        else:
            return {alias: (~ sub)}
    else:
        return {None: (~ reduce(combine, query.values()))}
