protected override void AdjustTree(Node node1, Node node2)
 {
     if (node1.Address.Equals(Root))
         return;
     if (Root.Equals(Address.Empty))
     {
         Type childType = node1 is Leaf ? typeof(Leaf) : typeof(Node);
         Node rootNode = new Node(Address.Empty, childType);
         Root = rootNode.Address;
         node1.Parent = Root;
         node2.Parent = Root;
         rootNode.AddNodeEntry(new NodeEntry(node1.CalculateMinimumBoundingBox(), node1.Address));
         rootNode.AddNodeEntry(new NodeEntry(node2.CalculateMinimumBoundingBox(), node2.Address));
         Cache.WritePageData(rootNode);
         //Node temp = Cache.LookupNode(rootNode.Address);
         Cache.WritePageData(node1);
         Cache.WritePageData(node2);
         TreeHeight++;
         return;
     }
     Node parent = Cache.LookupNode(node1.Parent);
     NodeEntry entryToUpdate = null;
     foreach (NodeEntry entry in parent.NodeEntries)
         if (entry.Child.Equals(node1.Address))
             entryToUpdate = entry;
     if (entryToUpdate == null)
     {
         MinimumBoundingBox mbb = node1.CalculateMinimumBoundingBox();
         IndexUnit indexUnit = new IndexUnit(parent.Address, node1.Address, mbb, Operation.Insert);
         NodeTranslationTable.Add(indexUnit);
         parent.AddNodeEntry(new NodeEntry(mbb, node1.Address));
     }
     else
     {
         MinimumBoundingBox mbb = node1.CalculateMinimumBoundingBox();
         IndexUnit indexUnit = new IndexUnit(parent.Address, entryToUpdate.Child, mbb, Operation.Update);
         NodeTranslationTable.Add(indexUnit);
         entryToUpdate.MinimumBoundingBox = mbb;
     }
     if (node2 != null)
     {
         MinimumBoundingBox mbb = node2.CalculateMinimumBoundingBox();
         IndexUnit indexUnit = new IndexUnit(parent.Address, node2.Address, mbb, Operation.Insert);
         NodeTranslationTable.Add(indexUnit);
         parent.AddNodeEntry(new NodeEntry(mbb, node2.Address));
         Cache.WritePageData(node2);
         Cache.WritePageData(node1);
         if (parent.NodeEntries.Count > Constants.MAXIMUM_ENTRIES_PER_NODE)
         {
             List<Node> splitNodes = Split(parent);
             if (parent.Address.Equals(Root))
                 Root = Address.Empty;
             RemoveFromParent(parent);
             AdjustTree(splitNodes[0], splitNodes[1]);
             return;
         }
     }
     AdjustTree(parent, null);
 }
 protected override void Insert(Node newNode, Node node)
 {
     MinimumBoundingBox mbb = newNode.CalculateMinimumBoundingBox();
     IndexUnit indexUnit = new IndexUnit(node.Address, newNode.Address, mbb, Operation.Insert);
     NodeTranslationTable.Add(indexUnit);
     node.AddNodeEntry(new NodeEntry(mbb, newNode.Address));
     newNode.Parent = node.Address;
     Cache.WritePageData(newNode);
 }
 protected virtual void Insert(Node newNode, Node node)
 {
     node.AddNodeEntry(new NodeEntry(newNode.CalculateMinimumBoundingBox(), newNode.Address));
     newNode.Parent = node.Address;
     Cache.WritePageData(node);
     Cache.WritePageData(newNode);
 }