// Overall strategy: if key is found in the node that has only a leaf as either
// of the two children, we can just delete the node. If it has a leaf as the right child,
// we can also delete the right child, update the nextLeafKey in the rightmost leaf of the left subtree,
// and we are done. Else, it has a leaf as the left child,
// so we copy the information from this left child leaf to the leftmost leaf in the right subtree,
// and delete the left child.
//
// Things get more complicated key is found in a node that has two non-leaf children.
// In that case, we perform a deleteMax operation on the left subtree
// (recursively call ourselves on the left child with
// with deleteMax = true), and copy the information from that deleted leaf into the node where the
// key was found and into the leftmost leaf of its right subtree
Overall strategy: if key is found in the node that has only a leaf as either
of the two children, we can just delete the node. If it has a leaf as the right child,
we can also delete the right child, update the nextLeafKey in the rightmost leaf of the left subtree,
and we are done. Else, it has a leaf as the left child,
so we copy the information from this left child leaf to the leftmost leaf in the right subtree,
and delete the left child.

Things get more complicated key is found in a node that has two non-leaf children.
In that case, we perform a deleteMax operation on the left subtree
(recursively call ourselves on the left child with
with deleteMax = true), and copy the information from that deleted leaf into the node where the
key was found and into the leftmost leaf of its right subtree
Overall strategy : if key is found in the node that has only a leaf as either of the two children we can just delete the node . If it has a leaf as the right child we can also delete the right child update the nextLeafKey in the rightmost leaf of the left subtree and we are done . Else it has a leaf as the left child so we copy the information from this left child leaf to the leftmost leaf in the right subtree and delete the left child . Things get more complicated key is found in a node that has two non - leaf children . In that case we perform a deleteMax operation on the left subtree ( recursively call ourselves on the left child with with deleteMax = true ) and copy the information from that deleted leaf into the node where the key was found and into the leftmost leaf of its right subtree
fn change_next_leaf_key_of_max_node(
        &mut self,
        r_node: &NodeId,
        next_leaf_key: &ADKey,
        operation: &Operation,
    ) -> NodeId {
        self.on_node_visit(r_node, operation, false);
        match self.tree().copy(r_node) {
            Node::Leaf(node) =>
                LeafNode::update(r_node, &node.hdr.key.unwrap(), &node.value, &next_leaf_key),
            Node::Internal(node) =>
                InternalNode::update(r_node, &node.left, &self.change_next_leaf_key_of_max_node(&node.right, next_leaf_key, operation), node.balance),
            _ =>
                panic!("Should never reach this point. If in prover, this is a bug. In in verifier, this proof is wrong.")
        }
    }
fn change_next_leaf_key_of_max_node ( & mut self , r_node : & NodeId , next_leaf_key : & ADKey , operation : & Operation , ) -> NodeId { self . on_node_visit ( r_node , operation , false ) ; match self . tree ( ) . copy ( r_node ) { Node :: Leaf ( node ) => LeafNode :: update ( r_node , & node . hdr . key . unwrap ( ) , & node . value , & next_leaf_key ) , Node :: Internal ( node ) => InternalNode :: update ( r_node , & node . left , & self . change_next_leaf_key_of_max_node ( & node . right , next_leaf_key , operation ) , node . balance ) , _ => panic ! ( " " ) } }
Overall strategy: if key is found in the node that has only a leaf as either
of the two children, we can just delete the node.
Overall strategy : if key is found in the node that has only a leaf as either of the two children we can just delete the node .
&mut self
r_node
&NodeId
next_leaf_key
&ADKey
operation
&Operation