private void ensureTypesMatch(ComponentType<?> type1, ComponentType<?> type2, String componentName) {
        if (!type1.equals(type2)) {
            throw new IllegalArgumentException("Two different types declared for the component with name '" + componentName +
                                               "' (" + type1.name + " != " + type2.name + ").");
        }
    }
@param ancestor The parent config producer
@param componentTypes The allowed component types for 'elementContainingComponentElements' - MUST match &lt;T&gt;
@param elementsContainingComponentElems All elements containing elements with name matching ComponentType.name
@param outerComponentTypeByComponentName Use null if this is the outermost scope, i.e.
                                         every component is a definition, not a reference.
config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/ComponentsBuilder.java