def get_mbean_name(location, existing_names, alias_helper):
    """
    Return the mbean name for the specified location.
    For unpredictable single folders:
      1. if an existing folder name is present, use that name as the mbean name.
      2. set the location's token to the mbean name.
    :param location: the location to examine
    :param existing_names: a list of existing names at the location
    :param alias_helper: the alias helper to use for name and path resolution
    """
    mbean_name = alias_helper.get_wlst_mbean_name(location)

    if alias_helper.requires_unpredictable_single_name_handling(location):
        if len(existing_names) > 0:
            mbean_name = existing_names[0]
        token = alias_helper.get_name_token(location)
        location.add_name_token(token, mbean_name)

    return mbean_name