Do not think of Accounts as nodes. Think of Emails as nodes!
Assign every unique email an ID ().
For each account, union all its emails together.
Group emails by their leader.
For each group, sort emails and prepend the account name.
This reframing makes the problem clean. The account name is metadata; the emails define connectivity. Time: where is the total number of emails across all accounts.