gchild->left->parent = gchild;
gchild->right = child;
- if(gchild->right)
- gchild->right->parent = gchild;
+ gchild->right->parent = gchild;
*superparent = gchild;
gchild->parent = parent;
balnode = parent;
} else {
subst = node->prev;
+ if(!subst) // This only happens if node is not actually in a tree at all.
+ abort();
if(subst == left) {
balnode = subst;