in reply to map & arrays & recursion

Because map is not a for loop?

map returns the results of its block. You push onto @nodes whatever $_->traversal() returns. What it returns you hide from us, but I guess it is not what you expect it to return. So, make your map block return what you want to push onto @nodes, then things should work as you might want them.