def METHOD_NAME(query):
    """
    Takes a Q object and extracts the underlying queries.  Returns an iterable
    of 3-tuples who's values are (negated, field_lookup, value)
    """
    if isinstance(query, tuple):
        return query
    return list(itertools.chain.from_iterable((
        (
            [tuple(itertools.chain.from_iterable(([query.negated], c)))]
            if isinstance(c, tuple)
            else METHOD_NAME(c)
        )
        for c in query.children
    )))