public static void CloneTree(
            VisualTreeAsset vta, VisualElement target,
            Dictionary <string, VisualElement> slotInsertionPoints,
            List <TemplateAsset.AttributeOverride> attributeOverrides)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if ((vta.visualElementAssets == null || vta.visualElementAssets.Count <= 0) &&
                (vta.templateAssets == null || vta.templateAssets.Count <= 0))
            {
                return;
            }

            var idToChildren = VisualTreeAssetUtilities.GenerateIdToChildren(vta);

            List <VisualElementAsset> rootAssets;

            // Tree root has parentId == 0
            idToChildren.TryGetValue(0, out rootAssets);
            if (rootAssets == null || rootAssets.Count == 0)
            {
                return;
            }

#if !UNITY_2019_4
            var uxmlRootAsset = rootAssets[0];

            vta.AssignClassListFromAssetToElement(uxmlRootAsset, target);
            vta.AssignStyleSheetFromAssetToElement(uxmlRootAsset, target);

            // Get the first-level elements. These will be instantiated and added to target.
            idToChildren.TryGetValue(uxmlRootAsset.id, out rootAssets);
            if (rootAssets == null || rootAssets.Count == 0)
            {
                return;
            }
#endif

            rootAssets.Sort(VisualTreeAssetUtilities.CompareForOrder);
            foreach (VisualElementAsset rootElement in rootAssets)
            {
                Assert.IsNotNull(rootElement);

                // Don't try to instatiate the special selection tracking element.
                if (rootElement.fullTypeName == BuilderConstants.SelectedVisualTreeAssetSpecialElementTypeName)
                {
                    continue;
                }

                VisualElement rootVe = CloneSetupRecursively(vta, rootElement, idToChildren,
                                                             new CreationContext(slotInsertionPoints, attributeOverrides, vta, target));

                // if contentContainer == this, the shadow and the logical hierarchy are identical
                // otherwise, if there is a CC, we want to insert in the shadow
                target.hierarchy.Add(rootVe);
            }
        }