+rbl_unlink_rbltree_branch(rbl_t *rbl)
+{
+ if(rbl->left)
+ rbl_unlink_rbltree_branch(rbl->left);
+
+ if(rbl->right)
+ rbl_unlink_rbltree_branch(rbl->right);
+
+ if(rbl->parent)
+ {
+ if(rbl == rbl->parent->left)
+ rbl->parent->left = NULL;
+ else
+ rbl->parent->right = NULL;
+ }
+}
+
+/* Optimized unlinking for a complete tree */
+void rbl_unlink_rbltree(rbltree_t *tree)
+{
+ rbl_t *rbl, *next;
+
+ for(rbl = tree->head; rbl; rbl = next)
+ {
+ next = rbl->next;
+ rbl->tree = NULL;
+ rbl->parent = NULL;
+ rbl->left = NULL;
+ rbl->right = NULL;
+ rbl->prev = NULL;
+ rbl->next = NULL;
+ }
+
+ tree->top = NULL;
+ tree->head = NULL;
+ tree->tail = NULL;
+}
+
+/* Optimized deletion for a complete tree */
+void rbl_delete_rbltree(rbltree_t *tree)
+{
+ rbl_t *rbl, *next;
+
+ for(rbl = tree->head; rbl; rbl = next)
+ {
+ next = rbl->next;
+ tree->delete(rbl->data);
+ }
+
+ tree->top = NULL;
+ tree->head = NULL;
+ tree->tail = NULL;
+}
+