Refactor ElementsIndexer.getNextElement to not use recursion

We are simply iterating over an array.  Recursion is overkill and a waste of memory when we are potentially iterating over thousands of elements.  Perhaps the recursion was left over from a previous algorithm that used binary search to find the element, but at this point it seems like a poor choice.
Merge pull request #1154 from colllin/patch-1

Refactor ElementsIndexer.getNextElement to not use recursion