Hi, I am experimenting with some custom iterators, and I’m wondering why this particular construction does not work as I would think (it returns nothing):

```
struct TreeNodeLeaves{T <: TreeNode}
node::T
end
function iterate(leaves::TreeNodeLeaves, state::Tuple{Vector{BranchNode}, Vector{Int}})
function transverse(substate::Tuple{Vector{BranchNode}, Vector{Int}})
if length(substate[1]) == 0
return nothing
end
current = pop!(substate[1])
if length(current.children) == 0
return ((current.data, copy(substate[2])), substate)
end
for index = eachindex(current.children)
nextnode = current.children[index]
push!(substate[1], nextnode)
push!(substate[2], index)
transverse(substate)
pop!(substate[2])
end
end
return transverse(state)
end
function iterate(leaves::TreeNodeLeaves)
nodes = Vector{BranchNode}()
indices = Int[]
push!(nodes, leaves.node)
return iterate(leaves, (nodes, indices))
end
```

The expected output is to return something like `("a", [2, 2, 1, 2, 2])`

from each iteration (where the integer array is the path to get to that node) until I’ve traversed the entire tree. If iterators are not the way to go with this, is there something else I can do such that I can iterate over something and get this type of return value with each iteration?