<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_by_name(account_name, bucket, region='us-west-2', json_path='accounts.json', alias=None):
 """Given an account name, attempts to retrieve associated account info."""

    for account in get_all_accounts(bucket, region, json_path)['accounts']:
        if 'aws' in account['type']:
            if account['name'] == account_name:
                return account
            elif alias:
                for a in account['alias']:
                    if a == account_name:
                        return account