I'm working with a german locale, so I have to translate from German to Englisch. Thus wording might be (slighty) wrong.
No need for apple script.
1. Open Mail.app
2. In the menu bar Choose Mailbox > New Smart Mailbox.
3. Give it an appropriate name like "All red mails"
4. Click on the DropDown box most left (as default it should say something like "From")
5. There should be something like "E-Mail with label/flag" (its a single option in the 5th group of the dropdown field). Select this. You should be able to select the color of the label in the next dropdown box.
Thanks for your screenshot, but I don't want to filter by flagged items, but by items that have a colour label (separate feature from the flag colours) - see screenshot - some flagged, some not flagged, but all different colours. I want to filter by yellow, green etc, whether flagged or not.
I got the labels via this script which I found online
tell application "Mail"
set maillist to selection
repeat with i from 1 to number of items in maillist
set this_item to item i of maillist
if class of this_item is message then
set background color of this_item to blue
-- other colors are
-- gray / green / orange / red