use a loop instead of recursion in CursorBasedIterator

servers with large sets of keys will cause memory and stack exhaustion if recursion is used
Rework PR to use "goto" instead of a "while ... do" loop.
Merge branch 'github/pr/182'