if (p->rb_link[1] == NULL)
  pa[k - 1]->rb_link[da[k - 1]] = p->rb_link[0];
else
  {
    enum rb_color t;
    struct rb_node *r = p->rb_link[1];

    if (r->rb_link[0] == NULL)
      {
        r->rb_link[0] = p->rb_link[0];
        t = r->rb_color;
        r->rb_color = p->rb_color;
        p->rb_color = t;
        pa[k - 1]->rb_link[da[k - 1]] = r;
        da[k] = 1;
        pa[k++] = r;
      }
    else
      {
        struct rb_node *s;
        int j = k++;

        for (;;)
          {
            da[k] = 0;
            pa[k++] = r;
            s = r->rb_link[0];
            if (s->rb_link[0] == NULL)
              break;

            r = s;
          }

        da[j] = 1;
        pa[j] = s;
        pa[j - 1]->rb_link[da[j - 1]] = s;

        s->rb_link[0] = p->rb_link[0];
        r->rb_link[0] = s->rb_link[1];
        s->rb_link[1] = p->rb_link[1];

        t = s->rb_color;
        s->rb_color = p->rb_color;
        p->rb_color = t;
      }
  }

