/* In an augmented interval tree, each node saves the maximum edge of its child subtrees This function compares the children max_edge with the current max_edge and propagates any change to the parent nodes.  */
static void update_max_edge(wmem_tree_node_t *node)
/* In an augmented interval tree, each node saves the maximum edge of its child subtrees This function compares the children max_edge with the current max_edge and propagates any change to the parent nodes.  */
static void update_max_edge(wmem_tree_node_t *node)
{
    wmem_range_t *range;
    wmem_range_t *range_l;
    wmem_range_t *range_r;
    guint64 maxEdge  = 0;
    if(!node) {
        return ;
    }
    range = (wmem_range_t *)node->key;
    range_l = (node->left) ? (wmem_range_t *) (node->left->key) : NULL;
    range_r = (node->right) ? (wmem_range_t *) (node->right->key) : NULL;
    maxEdge = range->max_edge;
    if(range_r) {
        maxEdge = MAX(maxEdge, range_r->max_edge) ;
    }
    if(range_l) {
        maxEdge = MAX(maxEdge, range_l->max_edge) ;
    }
    if(range->max_edge != maxEdge) {
        range->max_edge = maxEdge;
        update_max_edge(node->parent);
    }
}