private static void addNode(ConfigDefinition def, CNode node) {
        String name = node.getName();
        if (node instanceof LeafCNode) {
            if (node.isArray) {
                //System.out.println("Adding array node " + name);
                String enumValues = null;
                String type = ((LeafCNode) node).getType();
                if ("enum".equals(type)) {
                    enumValues = convertToEnumValueCommaSeparated(((LeafCNode.EnumLeaf) node).getLegalValues());
                }
                def.arrayDef(name).setTypeSpec(
                        new ConfigDefinition.TypeSpec(name, ((LeafCNode) node).getType(), null, enumValues, null, null));

            } else if (node.isMap) {
                //System.out.println("Adding leaf map node " + name);
                def.leafMapDef(name).setTypeSpec(new ConfigDefinition.TypeSpec(name, ((LeafCNode) node).getType(), null, null, null, null));
            } else {
                //System.out.println("Adding basic node " + name);
                if (node instanceof LeafCNode.IntegerLeaf) {
                    addNode(def, (LeafCNode.IntegerLeaf) node);
                } else if (node instanceof LeafCNode.LongLeaf) {
                    addNode(def, (LeafCNode.LongLeaf) node);
                } else if (node instanceof LeafCNode.BooleanLeaf) {
                    addNode(def, (LeafCNode.BooleanLeaf) node);
                } else if (node instanceof LeafCNode.DoubleLeaf) {
                    addNode(def, (LeafCNode.DoubleLeaf) node);
                    // Need to come before StringLeaf, since it is a subclass of StringLeaf
                } else if (node instanceof LeafCNode.ReferenceLeaf) {
                    addNode(def, (LeafCNode.ReferenceLeaf) node);
                } else if (node instanceof LeafCNode.FileLeaf) {
                    addNode(def, (LeafCNode.FileLeaf) node);
                } else if (node instanceof LeafCNode.PathLeaf) {
                    addNode(def, (LeafCNode.PathLeaf) node);
                } else if (node instanceof LeafCNode.OptionalPathLeaf) {
                    addNode(def, (LeafCNode.OptionalPathLeaf) node);
                } else if (node instanceof LeafCNode.UrlLeaf) {
                    addNode(def, (LeafCNode.UrlLeaf) node);
                } else if (node instanceof LeafCNode.ModelLeaf) {
                    addNode(def, (LeafCNode.ModelLeaf) node);
                } else if (node instanceof LeafCNode.StringLeaf) {
                    addNode(def, (LeafCNode.StringLeaf) node);
                } else if (node instanceof LeafCNode.EnumLeaf) {
                    addNode(def, (LeafCNode.EnumLeaf) node);
                } else {
                    System.err.println("Unknown node type for node with name '" + name + "'");
                }
            }
        } else {
            ConfigDefinition newDef;
            if (node.isArray) {
                if (node.getChildren() != null && node.getChildren().length > 0) {
                    newDef = def.innerArrayDef(name);
                    for (CNode childNode : node.getChildren()) {
                        addNode(newDef, childNode);
                    }
                }
            } else if (node.isMap) {
                newDef = def.structMapDef(name);
                if (node.getChildren() != null && node.getChildren().length > 0) {
                    for (CNode childNode : node.getChildren()) {
                        addNode(newDef, childNode);
                    }
                }

            } else {
                newDef = def.structDef(name);
                if (node.getChildren() != null && node.getChildren().length > 0) {
                    for (CNode childNode : node.getChildren()) {
                        addNode(newDef, childNode);
                    }
                }
            }
        }
    }
@param def a ConfigDefinition object
@param node the node to be added to the config definition
config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionBuilder.java