PropertyList result = target;
    private PropertyList resolveReferences(PropertyList target, int depth) throws CdlException {        if (depth > Constants.RESOLUTION_DEPTH_LIMIT) {            throw new CdlResolutionException(ReferencePath.ERROR_RECURSIVE_RESOLUTION                    + target.getDescription());        }        ResolveEnum state = target.getResolveState();        if (state == ResolveEnum.ResolvedComplete || state == ResolveEnum.ResolvedLazyLinksRemaining) {            return target;        }        boolean shouldResolve = target.isValueReference();        PropertyList result = target;        if (shouldResolve) {            //its a reference, process it            result = resolveReferenceNode(target);        } else {            if (state == ResolveEnum.ResolvedIncomplete) {                //there is something under here that needs resolving                //resolve child references                for (Node node : target.nodes()) {                    if (node instanceof PropertyList) {                        //cast it                        PropertyList template = (PropertyList) node;                        PropertyList newTemplate = resolveReferences(template, 0);                        if (template != newTemplate) {                            target.replaceChild(template, newTemplate);                            //then resolve it again, to get the children picked up                        }                    }                }            }        }        return result;    }