def first_realm_successful_strategy(authc_attempt):
    """
     The FirstRealmSuccessfulStrategy will iterate over the available realms
     and invoke Realm.authenticate_account(authc_token) on each one. The moment
     that a realm returns an Account without raising an Exception, that account
     is returned immediately and all subsequent realms ignored entirely
     (iteration 'short circuits').

     If no realms return an Account:
         * If only one exception was thrown by any consulted Realm, that
           exception is thrown.
         * If more than one Realm threw an exception during consultation, those
           exceptions are bundled together as a
           MultiRealmAuthenticationException and that exception is thrown.
         * If no exceptions were thrown, None is returned, indicating to the
           calling Authenticator that no Account was found (for that token)

    :type authc_attempt:  AuthenticationAttempt
    :returns:  Account
    """
    authc_token = authc_attempt.authentication_token
    realm_errors = []
    account = None
    for realm in authc_attempt.realms:
        if (realm.supports(authc_token)):
            try:
                account = realm.authenticate_account(authc_token)
            except Exception as ex:
                realm_errors.append(ex)
            if (account):
                    return account

    if (realm_errors):
        if (len(realm_errors) == 1):
            raise realm_errors[0]

        else:
            raise MultiRealmAuthenticationException(realm_errors)

    return None