else if (flag & M_THREAD_NEXT_NEW)
else if (flag & M_THREAD_NEXT_UNREAD)
int _mutt_traverse_thread (CONTEXT *ctx, HEADER *cur, int flag){  HEADER *roothdr = NULL, *top;  int final, reverse = (Sort & SORT_REVERSE), minmsgno;  int num_hidden = 0, unread = 0;  int min_unread_msgno = INT_MAX, min_unread = cur->virtual;#define CHECK_LIMIT (!ctx->pattern || cur->limited)  if ((Sort & SORT_MASK) != SORT_THREADS && !(flag & M_THREAD_GET_HIDDEN))  {    mutt_error ("Threading is not enabled.");    return (cur->virtual);  }  final = cur->virtual;  while (cur->parent)      cur = cur->parent;  top = cur;  minmsgno = cur->msgno;    if (!cur->read && CHECK_LIMIT)  {    unread = 1;    if (cur->msgno < min_unread_msgno)    {      min_unread = cur->virtual;      min_unread_msgno = cur->msgno;    }  }  if (cur->virtual == -1 && CHECK_LIMIT)    num_hidden++;  if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))  {    cur->collapsed = flag & M_THREAD_COLLAPSE;    if (cur->virtual != -1)    {      roothdr = cur;      if (flag & M_THREAD_COLLAPSE)	final = roothdr->virtual;    }  }  if ((cur = cur->child) == NULL)  {    /* return value depends on action requested */    if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))      return (final);    else if (flag & M_THREAD_UNREAD)      return (unread);    else if (flag & M_THREAD_GET_HIDDEN)      return (num_hidden);    else if (flag & M_THREAD_NEXT_NEW)      return (min_unread);  }    FOREVER  {    if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))    {      cur->collapsed = flag & M_THREAD_COLLAPSE;      if (!roothdr && CHECK_LIMIT)      {	roothdr = cur;	if (flag & M_THREAD_COLLAPSE)	  final = roothdr->virtual;      }      if (reverse && (flag & M_THREAD_COLLAPSE) && (cur->msgno < minmsgno) 	  && CHECK_LIMIT)      {	minmsgno = cur->msgno;	final = cur->virtual;      }      if (flag & M_THREAD_COLLAPSE)      {	if (cur != roothdr)	  cur->virtual = -1;      }      else       {	if (CHECK_LIMIT)	  cur->virtual = cur->msgno;      }    }    if (!cur->read && CHECK_LIMIT)    {      unread = 1;      if (cur->msgno < min_unread_msgno)      {	min_unread = cur->virtual;	min_unread_msgno = cur->msgno;      }    }    if (cur->virtual == -1 && CHECK_LIMIT)      num_hidden++;    if (cur->child)      cur = cur->child;    else if (cur->next)      cur = cur->next;    else    {      int done = 0;      while (!cur->next)      {	cur = cur->parent;	if (cur == top)	{	  done = 1;	  break;	}      }      if (done)	break;      cur = cur->next;    }  }  /* return value depends on action requested */  if (flag & (M_THREAD_COLLAPSE | M_THREAD_UNCOLLAPSE))    return (final);  else if (flag & M_THREAD_UNREAD)    return (unread);  else if (flag & M_THREAD_GET_HIDDEN)    return (num_hidden+1);  else if (flag & M_THREAD_NEXT_NEW)    return (min_unread);  return (0);#undef CHECK_LIMIT}