# cirq.flatten_op_tree¶

cirq.flatten_op_tree(root: Union[cirq.ops.raw_types.Operation, Iterable[Any]], preserve_moments: bool = False) → Iterable[Union[cirq.ops.raw_types.Operation, cirq.ops.moment.Moment]][source]

Performs an in-order iteration of the operations (leaves) in an OP_TREE.

Parameters: root – The operation or tree of operations to iterate. preserve_moments – Whether to yield Moments intact instead of flattening them Operations from the tree. TypeError – root isn’t a valid OP_TREE.