public int GetChildIndex(LeafNode searchingFor)
        {
            var childIter = child;
            int index;

            for (index = 0; index < ChildCount; index++)
            {
                if( childIter == null ) return -1;
                if( childIter == searchingFor ) break;

                childIter = childIter.GetRightSibling();
            }

            return index;
        }
 protected void SetRightSibling(LeafNode sibling)
 {
     rightSibling = sibling;
 }
 private void SetParent(LeafNode newParent)
 {
     parent = newParent;
 }
 protected void SetLeftSibling(LeafNode sibling)
 {
     leftSibling = sibling;
 }
        private void RemoveChild(LeafNode toBeRemoved)
        {
            if( toBeRemoved == null ) return; 
            
            if( toBeRemoved == GetFirstChild() )
            {
                child = toBeRemoved.GetRightSibling();
                if( child != null )
                {
                    child.SetLeftSibling( null );
                }
            }
            else
            {
                var siblingIter = child;
                while ( siblingIter != null && siblingIter != toBeRemoved ) 
                {
                    siblingIter = siblingIter.GetRightSibling();
                }

                if( siblingIter == toBeRemoved )
                {
                    if( toBeRemoved.HasLeftSibling() ) 
                    {
                        toBeRemoved.GetLeftSibling().SetRightSibling( toBeRemoved.GetRightSibling() );
                    }

                    if( toBeRemoved.HasRightSibling() )
                    {
                        toBeRemoved.GetRightSibling().SetLeftSibling( toBeRemoved.GetLeftSibling() );
                    }
                }
            }

            toBeRemoved.SetParent( null );
            toBeRemoved.SetLeftSibling( null );
            toBeRemoved.SetRightSibling( null );
            ChildCount--;
        }
        protected void AddChild(LeafNode newChild)
        {
            if( newChild.HasParent() )
            {
                newChild.GetParent().RemoveChild( newChild ); 
            }

            if( IsLeaf() )
            {
                SetChild( newChild );
                newChild.SetLeftSibling( null );
            }
            else
            {
                var siblingIter = child;
                while ( siblingIter != null && siblingIter.HasRightSibling() )
                {
                    siblingIter = siblingIter.GetRightSibling();
                }

                if( siblingIter != null )
                {
                    siblingIter.SetRightSibling( newChild );
                    newChild.SetLeftSibling( siblingIter );
                }
            }

            newChild.SetParent( this );
            ChildCount++;
        }
 protected void SetChild(LeafNode newChild)
 {
     child = newChild;
 }
 private LeafNode(LeafNode p,
     LeafNode o,
     LeafNode l,
     LeafNode r,
     int nC,
     int horizontalCoordinate,
     int verticalCoordinate,
     int w,
     int h,
     LeafNode prev,
     float preliminaryLocation,
     float mod)
 {
     parent = p;
     child = o;
     leftSibling = l;
     rightSibling = r;
     ChildCount = nC;
     HorizontalCoordinate = horizontalCoordinate;
     VerticalCoordinate = verticalCoordinate;
     width = w;
     height = h;
     LeftSibling = prev;
     PreliminaryLocation = preliminaryLocation;
     Modifier = mod;
 }