'Make some album fields equal across `self.items`. For the
RETAG action, we assume that the responsible for returning it
(ie. a plugin) always ensures that the first item contains
valid data on the relevant fields.'

def align_album_level_fields(self):

    changes = {}
    if (self.choice_flag == action.ASIS):
        (plur_albumartist, freq) = util.plurality([(i.albumartist or i.artist) for i in self.items])
        if ((freq == len(self.items)) or ((freq > 1) and ((float(freq) / len(self.items)) >= SINGLE_ARTIST_THRESH))):
            changes['albumartist'] = plur_albumartist
            changes['comp'] = False
        else:
            changes['albumartist'] = config['va_name'].as_str()
            changes['comp'] = True
    elif (self.choice_flag in (action.APPLY, action.RETAG)):
        if (not self.items[0].albumartist):
            changes['albumartist'] = self.items[0].artist
        if (not self.items[0].mb_albumartistid):
            changes['mb_albumartistid'] = self.items[0].mb_artistid
    for item in self.items:
        item.update(changes)
