Extract mailbox search to separate method

Adding mailboxes to the tree includes searching the tree for the parent
mailbox. The search code is generic and can be reused for other things.
Extract searching to a separate method available for reuse.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>