private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem node = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(curveBindings[0]));

            node.icon = GetIcon(curveBindings[0]);

            List <TreeViewItem>       childNodes             = new List <TreeViewItem>();
            List <EditorCurveBinding> singlePropertyBindings = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding curveBinding = curveBindings[i];

                singlePropertyBindings.Add(curveBinding);

                // We expect curveBindings to come sorted by propertyname
                if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName))
                {
                    TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node);
                    if (newNode != null)
                    {
                        childNodes.Add(newNode);
                    }
                    singlePropertyBindings.Clear();
                }
            }

            childNodes.Sort();

            TreeViewUtility.SetChildParentReferences(childNodes, node);
            return(node);
        }
        private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableObject, AnimationClip clip, TreeViewItem parent)
        {
            EditorCurveBinding[] allCurveBindings  = AnimationUtility.GetAnimatableBindings(scriptableObject);
            EditorCurveBinding[] availableBindings = allCurveBindings.Where(c => !AnimationWindowUtility.IsCurveCreated(clip, c)).ToArray();

            TreeViewItem node = null;

            if (availableBindings.Length > 0)
            {
                node = AddAnimatableObjectToHierarchy(availableBindings, parent, "");
            }
            else
            {
                node = new AddCurvesPopupObjectNode(parent, "", scriptableObject.name);
            }

            if (m_RootItem == null)
            {
                m_RootItem = node;
            }

            return(node);
        }