CachedNode node = rootNode();
for (Segment segment : path) {
ChildReferences children = node.getChildReferences(cache);
ChildReference child = children.getChild(segment);
if (child == null) {
throw new PathNotFoundException(path, node.getKey(), node.getPath(cache));
}
NodeKey childKey = child.getKey();
CachedNode childNode = cache.getNode(childKey);
if (childNode == null) {
throw new PathNotFoundException(path, node.getKey(), node.getPath(cache));
}
node = childNode;
}
assertThat(node, is(notNullValue()));
return node;