<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_version(self, name, url, mimetype=None, on_duplicate='error', **kwargs):
 """ Add a version of the text of this bill. :param name: a name given to this version of the text, e.g. 'As Introduced', 'Version 2', 'As amended', 'Enrolled' :param url: the location of this version on the legislative website. :param mimetype: MIME type of the document :param on_duplicate: What to do if a duplicate is seen: error - default option, raises a ValueError ignore - add the document twice (rarely the right choice) use_new - use the new name, removing the old document use_old - use the old name, not adding the new document If multiple formats are provided, a good rule of thumb is to prefer text, followed by html, followed by pdf/word/etc. """

        if not mimetype:
            raise ValueError('mimetype parameter to add_version is required')
        if on_duplicate != 'ignore':
            if url in self._seen_versions:
                if on_duplicate == 'error':
                    raise ValueError('duplicate version url %s' % url)
                elif on_duplicate == 'use_new':
                    # delete the old version
                    self['versions'] = [v for v in self['versions']
                                        if v['url'] != url]
                elif on_duplicate == 'use_old':
                    return       # do nothing
            self._seen_versions.add(url)

        d = dict(name=name, url=url, mimetype=mimetype, **kwargs)
        self['versions'].append(d)