if (p->rtrb_link[0] == NULL)
  {
    if (p->rtrb_rtag == RTRB_CHILD)
      {
        pa[k - 1]->rtrb_link[da[k - 1]] = p->rtrb_link[1];
      }
    else
      {
        pa[k - 1]->rtrb_link[da[k - 1]] = p->rtrb_link[da[k - 1]];
        if (da[k - 1] == 1)
          pa[k - 1]->rtrb_rtag = RTRB_THREAD;
      }
  }
else
  {
    enum rtrb_color t;
    struct rtrb_node *r = p->rtrb_link[0];

    if (r->rtrb_rtag == RTRB_THREAD)
      {
        r->rtrb_link[1] = p->rtrb_link[1];
        r->rtrb_rtag = p->rtrb_rtag;
        t = r->rtrb_color;
        r->rtrb_color = p->rtrb_color;
        p->rtrb_color = t;
        pa[k - 1]->rtrb_link[da[k - 1]] = r;
        da[k] = 0;
        pa[k++] = r;
      }
    else
      {
        struct rtrb_node *s;
        int j = k++;

        for (;;)
          {
            da[k] = 1;
            pa[k++] = r;
            s = r->rtrb_link[1];
            if (s->rtrb_rtag == RTRB_THREAD)
              break;

            r = s;
          }

        da[j] = 0;
        pa[j] = pa[j - 1]->rtrb_link[da[j - 1]] = s;

        if (s->rtrb_link[0] != NULL)
          r->rtrb_link[1] = s->rtrb_link[0];
        else
          {
            r->rtrb_rtag = RTRB_THREAD;
            r->rtrb_link[1] = s;
          }

        s->rtrb_link[0] = p->rtrb_link[0];
        s->rtrb_link[1] = p->rtrb_link[1];
        s->rtrb_rtag = p->rtrb_rtag;

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

