docs: private void validateChildNodeDefinition( JcrNodeDefinition childNodeDefinition,
                                                List<Name> supertypes,
                                                List<JcrNodeType> pendingTypes ) throws RepositoryException {
          if (childNodeDefinition.isAutoCreated() && !childNodeDefinition.isProtected()
              && childNodeDefinition.defaultPrimaryTypeName() == null) {
              throw new InvalidNodeTypeDefinitionException(JcrI18n.autocreatedNodesNeedDefaults.text(childNodeDefinition.getName()));
          }
          boolean residual = JcrNodeType.RESIDUAL_ITEM_NAME.equals(childNodeDefinition.getName());
          if (childNodeDefinition.isMandatory() && residual) {
              throw new InvalidNodeTypeDefinitionException(
                                                           JcrI18n.residualNodeDefinitionsCannotBeMandatory.text(childNodeDefinition.getName()));
          }
          if (childNodeDefinition.isAutoCreated() && residual) {
              throw new InvalidNodeTypeDefinitionException(
                                                           JcrI18n.residualNodeDefinitionsCannotBeAutoCreated.text(childNodeDefinition.getName()));
          }
  
          Name childNodeName = context.getValueFactories().getNameFactory().create(childNodeDefinition.getName());
          childNodeName = childNodeName == null ? JcrNodeType.RESIDUAL_NAME : childNodeName;
  
          List<JcrNodeDefinition> childNodesInAncestors = findChildNodeDefinitions(supertypes, childNodeName, NodeCardinality.ANY,
                                                                                   pendingTypes);
  
          for (JcrNodeDefinition childNodeFromAncestor : childNodesInAncestors) {
              if (childNodeFromAncestor.isProtected()) {
                  throw new InvalidNodeTypeDefinitionException(
                                                               JcrI18n.cannotOverrideProtectedDefinition.text(childNodeFromAncestor.getDeclaringNodeType()
                                                                                                                                   .getName(),
                                                                                                              "child node"));
              }
  
              if (childNodeFromAncestor.isMandatory() && !childNodeDefinition.isMandatory()) {
                  throw new InvalidNodeTypeDefinitionException(
                                                               JcrI18n.cannotMakeMandatoryDefinitionOptional.text(childNodeFromAncestor.getDeclaringNodeType()
                                                                                                                                       .getName(),
                                                                                                                  "child node"));
  
              }
  
              Name[] requiredPrimaryTypeNames = childNodeFromAncestor.requiredPrimaryTypeNames();
              for (Name requiredPrimaryTypeName : requiredPrimaryTypeNames) {
                  NodeType requiredPrimaryTypeFromAncestor = findTypeInMapOrList(requiredPrimaryTypeName, pendingTypes);
  
                  if (requiredPrimaryTypeFromAncestor == null) {
                      I18n msg = JcrI18n.couldNotFindDefinitionOfRequiredPrimaryType;
                      throw new InvalidNodeTypeDefinitionException(msg.text(requiredPrimaryTypeName, childNodeDefinition.getName(),
                                                                            childNodeDefinition.getDeclaringNodeType()));
  
                  }
  
                  boolean found = false;
  
                  for (Name name : childNodeDefinition.requiredPrimaryTypeNames()) {
                      JcrNodeType childNodePrimaryType = findTypeInMapOrList(name, pendingTypes);
  
                      if (childNodePrimaryType != null
                          && childNodePrimaryType.isNodeType(requiredPrimaryTypeFromAncestor.getName())) {
                          found = true;
                          break;
                      }
                  }
  
                  // Allow side-by-side definitions of residual child nodes per JCR 1.0.1 spec 6.7.8
                  if (!found && !residual) {
                      I18n msg = JcrI18n.cannotRedefineChildNodeWithIncompatibleDefinition;
                      throw new InvalidNodeTypeDefinitionException(msg.text(childNodeName,
                                                                            requiredPrimaryTypeFromAncestor.getName(),
                                                                            childNodeDefinition.getDeclaringNodeType()));
                  }
              }
          }
      }