/// <summary>
        /// Get First Child of TreeViewItem
        /// </summary>
        /// <returns>First Child</returns>
        public TreeViewItemContainerData FirstChild(VirtualizingTreeView treeView)
        {
            if (!HasChildren(treeView))
            {
                return(null);
            }

            int siblingIndex = treeView.IndexOf(Item);

            siblingIndex++;

            TreeViewItemContainerData child = (TreeViewItemContainerData)treeView.GetItemContainerData(siblingIndex);

            Debug.Assert(child != null && child.Parent == this);

            return(child);
        }
        public static void ExpandTo <T>(this VirtualizingTreeView treeView, T item, Func <T, T> getParent)
        {
            if (item == null)
            {
                return;
            }
            ItemContainerData containerData = treeView.GetItemContainerData(item);

            if (containerData == null)
            {
                treeView.ExpandTo(getParent(item), getParent);
                treeView.Expand(item);
            }
            else
            {
                treeView.Expand(item);
            }
        }
 public static void ExpandTo <T>(
     this VirtualizingTreeView treeView,
     T item,
     Func <T, T> getParent)
 {
     if ((object)item == null)
     {
         return;
     }
     if (treeView.GetItemContainerData((object)item) == null)
     {
         treeView.ExpandTo <T>(getParent(item), getParent);
         treeView.Expand((object)item);
     }
     else
     {
         treeView.Expand((object)item);
     }
 }
        /// <summary>
        /// Get Last Descendant Of TreeViewItem
        /// </summary>
        /// <returns>Last Descendant</returns>
        public TreeViewItemContainerData LastDescendant(VirtualizingTreeView treeView)
        {
            if (!HasChildren(treeView))
            {
                return(null);
            }

            int siblingIndex = treeView.IndexOf(Item);
            TreeViewItemContainerData lastDescendant = null;

            while (true)
            {
                siblingIndex++;
                TreeViewItemContainerData child = (TreeViewItemContainerData)treeView.GetItemContainerData(siblingIndex);

                if (child == null || !child.IsDescendantOf(this))
                {
                    return(lastDescendant);
                }

                lastDescendant = child;
            }
        }
        public TreeViewItemContainerData LastDescendant(
            VirtualizingTreeView treeView)
        {
            if (!this.HasChildren(treeView))
            {
                return((TreeViewItemContainerData)null);
            }
            int siblingIndex = treeView.IndexOf(this.Item);
            TreeViewItemContainerData itemContainerData1 = (TreeViewItemContainerData)null;

            while (true)
            {
                ++siblingIndex;
                TreeViewItemContainerData itemContainerData2 = (TreeViewItemContainerData)treeView.GetItemContainerData(siblingIndex);
                if (itemContainerData2 != null && itemContainerData2.IsDescendantOf(this))
                {
                    itemContainerData1 = itemContainerData2;
                }
                else
                {
                    break;
                }
            }
            return(itemContainerData1);
        }
        public TreeViewItemContainerData NextChild(
            VirtualizingTreeView treeView,
            TreeViewItemContainerData currentChild)
        {
            if (currentChild == null)
            {
                throw new ArgumentNullException(nameof(currentChild));
            }
            int siblingIndex = treeView.IndexOf(currentChild.Item) + 1;

            for (TreeViewItemContainerData itemContainerData = (TreeViewItemContainerData)treeView.GetItemContainerData(siblingIndex); itemContainerData != null && itemContainerData.IsDescendantOf(this); itemContainerData = (TreeViewItemContainerData)treeView.GetItemContainerData(siblingIndex))
            {
                if (itemContainerData.Parent == this)
                {
                    return(itemContainerData);
                }
                ++siblingIndex;
            }
            return((TreeViewItemContainerData)null);
        }