'Add a node to the where-tree. If the data is a list or tuple, it is
expected to be of the form (obj, lookup_type, value), where obj is
a Constraint object, and is then slightly munged before being stored
(to avoid storing any reference to field objects). Otherwise, the \'data\'
is stored unchanged and can be any class with an \'as_sql()\' method.'

def add(self, data, connector):

    if (not isinstance(data, (list, tuple))):
        super(WhereNode, self).add(data, connector)
        return
    (obj, lookup_type, value) = data
    if (hasattr(value, '__iter__') and hasattr(value, 'next')):
        value = list(value)
    if isinstance(value, datetime.datetime):
        annotation = datetime.datetime
    elif hasattr(value, 'value_annotation'):
        annotation = value.value_annotation
    else:
        annotation = bool(value)
    if hasattr(obj, 'prepare'):
        value = obj.prepare(lookup_type, value)
        super(WhereNode, self).add((obj, lookup_type, annotation, value), connector)
        return
    super(WhereNode, self).add((obj, lookup_type, annotation, value), connector)
