'Get list of aside fields that should be updated/inserted'

@contract(block_key=BlockKey)
def _get_asides_to_update_from_structure(self, structure, block_key, asides):

    block = self._get_block_from_structure(structure, block_key)
    if asides:
        updated = False
        tmp_new_asides_data = {}
        for asd in asides:
            aside_type = asd['aside_type']
            tmp_new_asides_data[aside_type] = asd
        result_list = []
        for (i, aside) in enumerate(block.asides):
            if (aside['aside_type'] in tmp_new_asides_data):
                result_list.append(tmp_new_asides_data.pop(aside['aside_type']))
                updated = True
            else:
                result_list.append(aside)
        if tmp_new_asides_data:
            for (_, asd) in tmp_new_asides_data.iteritems():
                result_list.append(asd)
                updated = True
        return (result_list, updated)
    else:
        return (block.asides, False)
