private Group getNextElement() {
            while (currentIndex + 1 < elements.length) {
                currentIndex++;
                Group element = null;
                try {
                    element = GroupManager.getInstance().getGroup(elements[currentIndex]);
                }
                catch (GroupNotFoundException unfe) {
                    Log.debug("Group not for element '{}' not found.", elements[currentIndex], unfe);
                }
                if (element != null) {
                    return element;
                }
            }
            return null;
        }
Returns the next available element, or null if there are no more elements to return.

@return the next available element.
xmppserver/src/main/java/org/jivesoftware/openfire/group/GroupCollection.java