private T nextResource() {
        while (true) {
            if (localResourceIterator != null && localResourceIterator.hasNext()) {
                return localResourceIterator.next();
            }
            if (!resourcePageIterator.hasNext()) {
                return null;
            }
            Page<T,R> resourcePage = resourcePageIterator.next();
            localResourceIterator = resourcePage.iterator();
        }
    }
Used to iterate through a list of resources already retrieved.
aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/internal/IteratorSupport.java