in src/main/java/org/apache/sling/resourceresolver/impl/providers/tree/PathTree.java [49:70]
public Node<T> getBestMatchingNode(final String path) {
if (path == null || path.isEmpty() || path.charAt(0) != '/') {
return null;
}
Node<T> result = root.getValue() != null ? root : null;
Node<T> node = root;
Iterator<String> it = new PathSegmentIterator(path, 1);
while (it.hasNext()) {
String segment = it.next();
node = node.getChild(segment);
if (node == null) {
break;
} else {
if (node.getValue() != null) {
result = node;
}
}
}
return result;
}