http://www.perlmonks.org?node_id=600538


in reply to Tree traversal without recursion: the tree as a state machine

It's no coincidence that stacks have a close relationship with trees.

You can get rid of any stacks whatsoever by keeping a parent pointer in the tree node data structure.

I wouldn't say you "get rid of any stacks" here.

While you don't implement the stack as a list in classical ways, the list of "parent pointer(s)" between the root and the current node at any given moment of the traversal forms a stack.

While traversing, you need no memory other than the current and the previous node/state.

"previous node/state" obviously refers to the "top of stack", the single point where a stack is accessible.