def q_children(q):
    todo = [q]
    while todo:
        q = todo.pop()
        for index, child in enumerate(q.children):
            if isinstance(child, Q):
                todo.append(child)
            else:
                yield child, q.children, index
Recursively visit a Q object, yielding each (key, value) pair found.
dataset/ETHPy150Open KristianOellegaard/django-hvad/hvad/query.py/q_children