Walks the tree of ops and builds a stack.
flatten_query(op, ops = list())
op
the current operation
ops
the stack of operations to append to, recursively