+ private GeneratedTypeBuilder findChildOfType(final ChoiceSchemaNode targetNode) {
+ final SchemaPath nodePath = targetNode.getPath();
+ final SchemaPath parentSp = nodePath.getParent();
+ if (parentSp.getParent() == null) {
+ return moduleContext(nodePath.getLastComponent().getModule()).getModuleNode();
+ }
+
+ final SchemaNode parent = findDataSchemaNode(schemaContext, parentSp);
+ GeneratedTypeBuilder childOfType = null;
+ if (parent instanceof CaseSchemaNode) {
+ childOfType = findCaseByPath(parent.getPath());
+ } else if (parent instanceof DataSchemaNode || parent instanceof NotificationDefinition) {
+ childOfType = findChildNodeByPath(parent.getPath());
+ } else if (parent instanceof GroupingDefinition) {
+ childOfType = findGroupingByPath(parent.getPath());
+ }
+
+ if (childOfType == null) {
+ throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode);
+ }
+
+ return childOfType;
+ }
+