public Node RemoveEnd()
        {
            Node oldTail = _tail;

            if (_tail == null) // no nodes
            {
                return(null);
            }
            else if (_head == _tail) //one node
            {
                _head = null;
                _tail = null;
            }
            else //two or more nodes
            {
                Node secondLast = _tail.Parent;
                _tail = secondLast;
                _tail.SetChild(null);
            }

            Size--;

            oldTail.SetChild(null);
            oldTail.SetParent(null);
            return(oldTail);
        }
        public void SetChildTest()
        {
            Node child = new Node(null, null, new Element(new byte[0]), 0);

            Node n = new Node(null, null, new Element(new byte[0]), 1);

            n.SetChild(child);

            Assert.AreEqual(child, n.Child);
        }
        private void InsertAtHead(Node n)
        {
            n.SetParent(null);
            n.SetChild(_head);

            if (_head == null) // no nodes yet
            {
                Debug.Assert(_tail == null);
                _tail = n;
            }
            if (_head != null) // at least one node in the list
            {
                _head.SetParent(n);
            }
            _head = n;
        }
        private void InsertAtHead(Node n)
        {
            n.SetParent(null);
            n.SetChild(_head);

            if (_head == null) // no nodes yet
            {
                Debug.Assert(_tail == null);
                _tail = n;
            }
            if (_head != null) // at least one node in the list
            {
                _head.SetParent(n);
            }
            _head = n;
        }
        public Node RemoveEnd()
        {
            Node oldTail = _tail;
            if (_tail == null) // no nodes
            {
                return null;
            }
            else if (_head == _tail) //one node
            {
                _head = null;
                _tail = null;
            }
            else //two or more nodes
            {
                Node secondLast = _tail.Parent;
                _tail = secondLast;
                _tail.SetChild(null);
            }

            Size--;

            oldTail.SetChild(null);
            oldTail.SetParent(null);
            return oldTail;
        }