Hi,
Can i "group by" e-mails based on custom header in imap?

According to my experience if i use "XX UID SEARCH INTHREAD REFS HEADER myheader myvalue" i receiveĀ  emails UID gathers by HEADER+VALUE, but in this way i need to fetch all emails using several imap SEARCH.

Has dovecot any features that would help me do this?

Thank you!!