'A preprocessor for the internal _add_q(). Responsible for
splitting the given q_object into where and having parts and
setting up some internal variables.'

def add_q(self, q_object):

    if (not self.need_having(q_object)):
        (where_part, having_parts) = (q_object, [])
    else:
        (where_part, having_parts) = self.split_having_parts(q_object.clone(), q_object.negated)
    used_aliases = self.used_aliases
    clause = self._add_q(where_part, used_aliases)
    self.where.add(clause, AND)
    for hp in having_parts:
        clause = self._add_q(hp, used_aliases)
        self.having.add(clause, AND)
    if self.filter_is_sticky:
        self.used_aliases = used_aliases
