public void MoveElements(TreeElement parentElement, int insertionIndex, List <TreeElement> elements)
        {
            if (insertionIndex < 0)
            {
                throw new ArgumentException("Invalid input: insertionIndex is -1, client needs to decide what index elements should be re parented at");
            }

            // Invalid re-parenting input
            if (parentElement == null)
            {
                return;
            }

            // We are moving items so we adjust the insertion index to accommodate that any items above the insertion index is removed before inserting
            if (insertionIndex > 0)
            {
                insertionIndex -= parentElement.Children.GetRange(0, insertionIndex).Count(elements.Contains);
            }

            // Remove draggedItems from their parents
            foreach (var draggedItem in elements)
            {
                draggedItem.Parent.Children.Remove(draggedItem);                    // remove from old parent
                draggedItem.Parent = parentElement;                                 // set new parent
            }

            if (parentElement.Children == null)
            {
                parentElement.Children = new List <TreeElement>();
            }

            // Insert dragged items under new parent
            parentElement.Children.InsertRange(insertionIndex, elements);

            TreeElementUtility.UpdateDepthValues(Root);
            TreeElementUtility.TreeToList(m_Root, m_Data);

            Changed();
        }
        public void RemoveElements(IList <T> elements)
        {
            foreach (var element in elements)
            {
                if (element == m_Root)
                {
                    throw new ArgumentException("It is not allowed to remove the root element");
                }
            }

            var commonAncestors = TreeElementUtility.FindCommonAncestorsWithinList(elements);

            foreach (var element in commonAncestors)
            {
                element.Parent.Children.Remove(element);
                element.Parent = null;
            }

            TreeElementUtility.TreeToList(m_Root, m_Data);

            Changed();
        }
 public void UpdateDataFromTree()
 {
     TreeElementUtility.TreeToList(m_Root, m_Data);
 }