I think this check is necessary b/c of line 100 - iter.next() will throw an exception if there are no more elements.