def profile_emails(profile, get_unverified=False):
    """Return a dict of user profile's emails,
    divided into primary, rest and optionally unverified.
    Also pass their total count.
    """
    emails = profile.emails.filter(verified=True).order_by('-primary')
    result = {'primary': emails[0], 'secondary': emails[1:]}
    count = len(emails)
    if get_unverified:
        result['unverified'] = profile.emails.filter(verified=False)
        count += len(result['unverified'])
    result['count'] = count
    return result
