- static final DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) {
- DataSchemaNode potential = parent.getDataChildByName(child);
- if (potential == null) {
- Iterable<org.opendaylight.yangtools.yang.model.api.ChoiceNode> choices = FluentIterable.from(
- parent.getChildNodes()).filter(ChoiceNode.class);
- potential = findChoice(choices, child);
+ /**
+ * Find a child node as identified by a {@link YangInstanceIdentifier} relative to this node.
+ *
+ * @param path Path towards the child node
+ * @return Child node if present, or empty when corresponding child is not found.
+ * @throws NullPointerException if {@code path} is null
+ */
+ public final @NonNull Optional<@NonNull DataSchemaContextNode<?>> findChild(
+ final @NonNull YangInstanceIdentifier path) {
+ DataSchemaContextNode<?> currentOp = this;
+ for (PathArgument arg : path.getPathArguments()) {
+ currentOp = currentOp.getChild(arg);
+ if (currentOp == null) {
+ return Optional.empty();
+ }