Something feels a little "inside-out" about this code, maybe related to your comment above. Could this be replaced function be something like `iter_control_nodes(self)`, and then replace the `leaf_callback(...` and `all_callback(...` lines with

```python
yield (node, path, repeat_context, items)
```
and 

```python
yield (node, path, repeat_context, None)
```

respectively.

Then you replace a call `xform.for_each_leaf_control_node(leaf_callback, all_callback)` with

```python
for node, path, repeat_context, items in xform.iter_control_nodes():
    if items is None:
        all_callback(node, path, repeat_context, items)
    else:
        leaf_callback(node, path, repeat_context, items)
```