Implementing Iterator on stack