cur->prev->next = cur->next;  if (cur->next) cur->next->prev = cur->prev; } else { if (cur->next) cur->next->prev = NULL; *top = cur->next;
for (tmp = cur->parent; tmp && tmp->sort_key == cur->sort_key; tmp = tmp->parent) tmp->sort_key = NULL;
static void unlink_message (THREAD **top, THREAD *cur){  if (cur->prev)  {    cur->prev->next = cur->next;    if (cur->next)      cur->next->prev = cur->prev;  }  else  {    if (cur->next)      cur->next->prev = NULL;    *top = cur->next;  }}