public class TreeShapedStack<T>
Represents a stack where one prefix of the stack can branch in
several directions. Calling "push" on this object returns a new
object which points to the previous state. Calling "pop" returns a
pointer to the previous state. The only way to access the current
node's information is with "peek".
Note that if you have an earlier node in the tree, you have no way
of recovering later nodes. It is essential to keep the ends of the
stack you are interested in.