Implement without use of mutable stack

IMHO the algorithm is simpler in this form also
Merge pull request #8 from crisptrutski/no-mutable-state

No mutable state