protected virtual void CloneTree(openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT adlComplexObject, C_COMPLEX_OBJECT parentComplexObject, int depth)
        {
            CloneConstraintVisitor nodeVisitor = NewInstance();

            openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE adlAttribute;
            parentComplexObject.attributes = new C_ATTRIBUTE[adlComplexObject.attributes().count()];

            for (int i = 1; i <= adlComplexObject.attributes().count(); i++)
            {
                adlAttribute = adlComplexObject.attributes().i_th(i) as openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE;
                C_ATTRIBUTE attributeNode = nodeVisitor.CloneAttribute(adlAttribute);
                attributeNode.children = new C_OBJECT[adlAttribute.children().count()];
                parentComplexObject.attributes[i - 1] = attributeNode;

                for (int j = 1; j <= adlAttribute.children().count(); j++)
                {
                    openehr.openehr.am.archetype.constraint_model.C_OBJECT child = adlAttribute.children().i_th(j) as openehr.openehr.am.archetype.constraint_model.C_OBJECT;
                    object childNode = nodeVisitor.Visit(child, depth);
                    attributeNode.children[j - 1] = childNode as C_OBJECT;

                    if (child is openehr.openehr.am.archetype.constraint_model.Impl.C_COMPLEX_OBJECT)
                        CloneTree(child as openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT, childNode as C_COMPLEX_OBJECT, ++depth);
                }
            }
        }