newChildren.add(copiedList);  entries.put(name, name);
    private PropertyList inheritChildren(PropertyList target,            PropertyList extension)            throws CdlException {        //max size of our list is the sum of all children        int maxsize = target.getChildCount() +                extension.getChildCount();        //list of elements (this retains the overall order of things)        List<Node> newChildren = new ArrayList<Node>(maxsize);        //this is a map that caches mappings of things        HashMap<QName, QName> entries = new HashMap<QName, QName>(maxsize);        for (Node node : extension.nodes()) {            if (node instanceof PropertyList) {                //cast it                PropertyList template = (PropertyList) node;                QName name = template.getQName();                //merge it                ResolveResult resolved = resolveExtends(template);                PropertyList resolvedList = resolved.getResolvedPropertyList();                //now, at this point we have a property list which contains                //a resolved element. We are going to get that element out because                //it is what we want.                //now, look for a match locally                PropertyList matchedList = target.mapToPropertyList(                        resolvedList);                if (matchedList == null) {                    //insert a copy of the resolved element.                    //the copy is needed in case it gets manipulated later                    PropertyList copiedList = (PropertyList) resolvedList.copy();                    newChildren.add(copiedList);                    //register in the cache of mapped things.                    entries.put(name, name);                } else {                    //complex merge.                    //first, pull in the attributes of the child                    matchedList.inheritAttributes(resolvedList);                    //then insert the children of the current list into place                    newChildren.add(matchedList);                    entries.put(name, name);                }            } else {                //something other than Element; could be Text                newChildren.add(node);            }        }        //now we run through the local list, and if there is any        // element not found in the remote, add it to the end        // all nodes get added too.        List<Node> leftovers = copyAndResolve(target, entries);        newChildren.addAll(leftovers);        //as this point our element list is updated, and the mappings list contains        //a mapping for every element that we have used. So, what do we do now.        //two options:        // 1: create a new parent element, set up the children and delegate to ourselves        // 2: patch stuff together by hand.        return replaceNode(target, newChildren);    }