(q, phrases=True)
Returns the terms in the query tree, with the query hierarchy
    represented as nested lists.
Returns the terms in the query tree, with the query hierarchy
    represented as nested lists.
Returns the terms in the query tree with the query hierarchy represented as nested lists .
def token_lists(q, phrases=True):
    """Returns the terms in the query tree, with the query hierarchy
    represented as nested lists.
    """

    if q.is_leaf():
        from whoosh.query import Phrase
        if phrases or not isinstance(q, Phrase):
            return list(q.tokens())
    else:
        ls = []
        for qq in q.children():
            t = token_lists(qq, phrases=phrases)
            if len(t) == 1:
                t = t[0]
            if t:
                ls.append(t)
        return ls
def token_lists ( q , phrases = True ) : if q . is_leaf ( ) : from whoosh . query import Phrase if phrases or not isinstance ( q , Phrase ) : return list ( q . tokens ( ) ) else : ls = [ ] for qq in q . children ( ) : t = token_lists ( qq , phrases = phrases ) if len ( t ) == 1 : t = t [ 0 ] if t : ls . append ( t ) return ls