def METHOD_NAME(task: et.Element, ds: datastore) -> Optional[et.Element]:
    """Convert old task XML into the new format."""
    tid = task.attrib['id']
    real_task = ds.task_factory(tid)
    if task is None:
        return
    # Get the old task properties
    # TIDs were stored as UUID, but sometimes they were not present
    tid = task.get('uuid') or real_task.get_uuid() or tid_cache[tid]
    status = task.get('status')
    title = task.find('title').text
    content = task.find('content')
    try:
        done_date = task.find('donedate').text
    except AttributeError:
        done_date = None
    try:
        due_date = task.find('duedate').text
    except AttributeError:
        due_date = None
    try:
        modified = task.find('modified').text
    except AttributeError:
        modified = None
    try:
        added = task.find('added').text
    except AttributeError:
        added = None
    try:
        start = task.find('startdate').text
    except AttributeError:
        start = None
    # Build the new task
    new_task = et.Element('task')
    new_task.set('status', status)
    new_task.set('id', tid)
    new_title = et.SubElement(new_task, 'title')
    new_title.text = title
    tags = et.SubElement(new_task, 'tags')
    for tag_name in task.get('tags').split(','):
        if tag_name:
            tag_id = tags_cache[tag_name]
            task_tag = et.SubElement(tags, 'tag')
            task_tag.text = tag_id
    dates = et.SubElement(new_task, 'dates')
    new_added = et.SubElement(dates, 'added')
    new_modified = et.SubElement(dates, 'modified')
    if added:
        added = str(Date(added))
    else:
        added = date.today().isoformat()
    new_added.text = added
    if modified:
        modified = modified[:10]
        modified = str(Date(modified))
    else:
        modified = date.today().isoformat()
    new_modified.text = modified
    if done_date:
        new_done = et.SubElement(dates, 'done')
        new_done.text = str(Date(done_date))
    if start:
        start = Date(start)
        if start.is_fuzzy():
            new_start = et.SubElement(dates, 'fuzzyStart')
        else:
            new_start = et.SubElement(dates, 'start')
        new_start.text = str(start)
    if due_date:
        due_date = Date(due_date)
        if due_date.is_fuzzy():
            new_due = et.SubElement(dates, 'fuzzyDue')
        else:
            new_due = et.SubElement(dates, 'due')
        new_due.text = str(due_date)
    recurring = et.SubElement(new_task, 'recurring')
    recurring.set('enabled', 'false')
    subtasks = et.SubElement(new_task, 'subtasks')
    for sub in task.findall('subtask'):
        new_sub = et.SubElement(subtasks, 'sub')
        new_sub.text = tid_cache[sub.text]
    new_content = et.SubElement(new_task, 'content')
    if content is not None:
        new_content.text = et.CDATA(convert_content(content.text))
    else:
        new_content.text = et.CDATA('')
    return new_task