- if(rootPath.contains(childPath)) {
- int common = rootPath.getPath().size();
- InstanceIdentifier relativePath = new InstanceIdentifier(childPath.getPath().subList(common, childPath.getPath().size()));
- return findNode(rootNode, relativePath);
+ final Optional<InstanceIdentifier> relativePath = childPath.relativeTo(rootPath);
+ if (relativePath.isPresent()) {
+ return findNode(rootNode, relativePath.get());
+ } else {
+ return Optional.absent();