In Mail app, how can I go (jump) to the folder (mailbox) of a selected message in a search result view or in a Smart Mailbox?
Solution using AppleScript

The solution I found was to create an Automator service and associate it to a shortcut.


Open Automator
New Document
Select "Service" for the type of document
At the top of the window, set the following options:
Service receives selected >> no input
in >> Mail.app
In the Actions library (left pane) find the action "Run AppleScript"
Drag and drop it in the workflow area
Copy the code at the end of this answer and paste it into the action "Run AppleScript"
Save your service (e.g. "Jump to Folder")


Test the service


No need to close automator or relaunch Mail.
Do a search and select a message (preferably a message filed in some custom folder).
Go to Mail >> Services. You should see your new service
Apply the service.


Your selected and active mailbox should be the mailbox of the previously selected message.

Optional

Assign a shortcut (e.g. CONTROL-COMMAND-J) to your service:


System Preferences >> Keyboard >> Shortcuts >> Services.
At the end of the right pane under General you should find your service.
Assign a shortcut to it.


The Code

set theDialogTitle to "Jump to Folder Script"

tell application "Mail"

    -- Get the selected messages and the count of them
    set theMessageList to selected messages of message viewer 1
    set theCount to length of theMessageList

    -- Error if no messages
    if theCount is 0 then
        display dialog ¬
            "No message selected." with title theDialogTitle buttons {"OK"} with icon caution
        return
    end if

    -- Error if more than one message
    if theCount is greater than 1 then
        display dialog ¬
            "Must select only one message." with title theDialogTitle buttons {"OK"} with icon caution
        return
    end if

    -- Get the message
    set theMessage to item 1 of theMessageList

    -- Get the mailbox object
    set theMailbox to mailbox of theMessage

    -- Select the mailbox
    set selected mailboxes of message viewer 1 to theMailbox

end tell