use a loop instead of recursion in CursorBasedIterator

servers with large sets of keys will cause memory and stack exhaustion if recursion is used

intended to fix #181, works for me but welcome a cleaner solution