- final DataSchemaNode child = current.getDataChildByName(qname);
- Preconditions.checkArgument(child instanceof DataNodeContainer);
- current = (DataNodeContainer) child;
+ final DataSchemaNode child;
+ if(current instanceof DataNodeContainer) {
+ child = ((DataNodeContainer) current).getDataChildByName(qname);
+ } else if (current instanceof ChoiceNode) {
+ child = ((ChoiceNode) current).getCaseNodeByName(qname);
+ } else {
+ throw new IllegalArgumentException(String.format("Schema node %s does not allow children.",current));
+ }
+ current = child;