@Override
public Iterator<Resource> apply(Resource resource) {
Resource current = resource;
while (current != null) {
Iterator<Resource> iterator = new ArrayIterator(current);
iterator = selector.apply(iterator);
if (iterator.hasNext()) {
return iterator;
}
current = current.getParent();
}
return EmptyIterator.INSTANCE;