code: void balance(
      int           t0_depth,
      DeleteStack   stack)
  
    {
      int ntop = stack.topIndex();
      InsertStack istack = stack.insertStack();
      DeleteStack.Linearizer lxx = stack.linearizer();
      DeleteStack.FringeNote  xx = stack.fringeNote();
      xx.depthDecrease = false;
      xx.conditionalDecrease = false;
      GBSNode f = stack.node(ntop);  /* Father of the t0 fringe               */
      if (ntop == 0)                 /* Final t0 fringe is to go away         */
        {                            /* Make final sub-tree a list            */
          f.setRightChild(linearize(lxx, f.rightChild()));
          return;                    /* Nothing left to do                    */
        }
      GBSNode g = stack.node(ntop-1);/* Grandparent of the fringe             */
      boolean gLeft = true;
      if (g.rightChild() == f) {
        gLeft = false;
      }
  
      if (f.leftChild() == stack.node(ntop+1)) { /* Deleted from left         */
        leftFringe(lxx, xx, istack, f, g, gLeft, t0_depth);
      }
      else {                                     /* Deleted from right        */
        rightFringe(lxx, xx, istack, f, g, gLeft);
      }
      lastFringe(xx, g, gLeft, stack, ntop, istack);
    }
docs: Balance a fringe following delete.