This whole implementation would be a lot cleaner using Guava's AbstractIterator.  It would effectively be a 3 line method.