Refactoring the Account._resolve_group() and Group._resolve_account() helpers.

They now operate properly in all conditions, and are simpler to read through.