'Returns whether or not all elements of this q_object need to be put
together in the HAVING clause.'

def need_having(self, obj):

    if (not isinstance(obj, Node)):
        return (refs_aggregate(obj[0].split(LOOKUP_SEP), self.aggregates) or (hasattr(obj[1], 'contains_aggregate') and obj[1].contains_aggregate(self.aggregates)))
    return any((self.need_having(c) for c in obj.children))
