private Option getDescendant()

in src/main/java/org/apache/sling/query/impl/iterator/DescendantsIterator.java [58:69]


    private Option<T> getDescendant() {
        while (descendants.hasNext()) {
            T descendantCandidate = descendants.next();
            if (provider.isDescendant(current.getElement(), descendantCandidate)) {
                descendants.remove();
                return Option.of(descendantCandidate, current.getArgumentId());
            }
        }
        Option<T> result = Option.empty(current.getArgumentId());
        current = null;
        return result;
    }