private void readConfigModels(ApplicationConfigProducerRoot root,
                                  Element servicesRoot,
                                  DeployState deployState,
                                  VespaModel vespaModel,
                                  ConfigModelRegistry configModelRegistry) {
        final Map<ConfigModelBuilder, List<Element>> model2Element = new LinkedHashMap<>();
        ModelGraphBuilder graphBuilder = new ModelGraphBuilder();

        final List<Element> children = getServiceElements(servicesRoot);

        if (XML.getChild(servicesRoot, "admin") == null)
            children.add(getImplicitAdmin(deployState));

        for (Element servicesElement : children) {
            String tagName = servicesElement.getTagName();
            if (tagName.equals("legacy")) {
                // for enabling legacy features from old vespa versions
                continue;
            }
            if (tagName.equals("config")) {
                // Top level config, mainly to be used by the Vespa team.
                continue;
            }

            String tagVersion = servicesElement.getAttribute("version");
            ConfigModelId xmlId = ConfigModelId.fromNameAndVersion(tagName, tagVersion);

            Collection<ConfigModelBuilder> builders = configModelRegistry.resolve(xmlId);

            if (builders.isEmpty())
                throw new IllegalArgumentException("Could not resolve tag <" + tagName + " version=\"" + tagVersion + "\"> to a config model component");

            for (ConfigModelBuilder builder : builders) {
                if ( ! model2Element.containsKey(builder)) {
                    model2Element.put(builder, new ArrayList<>());
                    graphBuilder.addBuilder(builder);
                }
                model2Element.get(builder).add(servicesElement);
            }
        }

        for (ModelNode node : graphBuilder.build().topologicalSort())
            buildModels(node, getApplicationType(servicesRoot), deployState, vespaModel, root, model2Element.get(node.builder));
        for (ConfigModel model : configModels)
            model.initialize(ConfigModelRepo.this); // XXX deprecated
    }
Creates all the config models specified in the given XML element and
passes their respective XML node as parameter.

@param root The Root to set as parent for all plugins
@param servicesRoot XML root node of the services file
config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java