/// <summary>Retrieves the first ancestor of a node that still exists as a descendent of the root node.</summary>
 /// <param name="root">The root node.</param>
 /// <param name="orphan">The orphaned node.</param>
 /// <remarks>Useful for when a node is removed, and you want to move a view to the reamining parent.</remarks>
 public ITreeNode FirstRemainingParent(ITreeNode root, ITreeNode orphan)
 {
     if (root == null || orphan == null) return null;
     ITreeNode parent = orphan.Parent;
     do
     {
         if (parent == null) break;
         if (parent == root || root.ContainsDescendent(parent)) return parent;
         parent = parent.Parent;
     } while (parent != null);
     return null;
 }
 private static HorizontalEdge GetSlideDirection(ITreeNode previousNode, ITreeNode newNode)
 {
     if (previousNode == null) return HorizontalEdge.Left;
     return previousNode.ContainsDescendent(newNode) 
                ? HorizontalEdge.Left 
                : HorizontalEdge.Right;
 }