def METHOD_NAME(self, loc, dictionary):
    """
        Writes the supplied dictionary back to the advancedsettings.xml file
    """
    if not dictionary.get('advancedsettings', None):
        self.log('Empty dictionary passed to advancedsettings file writer. '
                 'Preventing write, backing up and removing file.')
        subprocess.call(['sudo', 'cp', loc, loc.replace('advancedsettings.xml',
                                                        'advancedsettings_backup.xml')])
        subprocess.call(['sudo', 'rm', '-f', loc])
        return
    with open(loc, 'w', encoding='utf-8') as open_file:
        xmltodict.unparse(input_dict=dictionary, output=open_file, pretty=True)