code: def untlpy2etd_ms(untl_elements, **kwargs):
      degree_children = {}
      date_exists = False
      seen_creation = False
      etd_ms_root = ETD_MS_CONVERSION_DISPATCH['thesis']()
      for element in untl_elements.children:
          etd_ms_element = None
          if element.tag in ETD_MS_CONVERSION_DISPATCH:
              if element.children:
                  etd_ms_element = ETD_MS_CONVERSION_DISPATCH[element.tag](
                      qualifier=element.qualifier,
                      children=element.children,
                  )
              elif element.tag == 'degree':
                  if element.qualifier in ['name',
                                           'level',
                                           'discipline',
                                           'grantor']:
                      degree_children[element.qualifier] = element.content
              elif element.tag == 'date':
                  if element.qualifier == 'creation':
                      for child in etd_ms_root.children:
                          if child.tag == 'date':
                              del child
                              if not seen_creation:
                                  date_exists = False
                      seen_creation = True
                      if not date_exists:
                          etd_ms_element = ETD_MS_CONVERSION_DISPATCH[element.tag](
                              qualifier=element.qualifier,
                              content=element.content,
                          )
                          date_exists = True
              elif element.tag not in ['date', 'degree']:
                  etd_ms_element = ETD_MS_CONVERSION_DISPATCH[element.tag](
                      qualifier=element.qualifier,
                      content=element.content,
                  )
              if etd_ms_element:
                  etd_ms_root.add_child(etd_ms_element)
          if element.tag == 'meta':
              ark = False
              for i in etd_ms_root.children:
                  if i.tag == 'identifier' and i.content.startswith(
                      'http://digital.library.unt.edu/'
                  ):
                      ark = True
              if not ark:
                  ark = False
                  if element.qualifier == 'ark':
                      ark = element.content
                  if ark is not None:
                      ark_identifier = ETD_MS_CONVERSION_DISPATCH['identifier'](
                          ark=ark,
                      )
                      etd_ms_root.add_child(ark_identifier)
      if degree_children:
          degree_element = ETD_MS_CONVERSION_DISPATCH['degree']()
          degree_child_element = None
          for k, v in degree_children.iteritems():
              degree_child_element = ETD_MS_DEGREE_DISPATCH[k](
                  content=v,
              )
              if degree_child_element:
                  degree_element.add_child(degree_child_element)
          etd_ms_root.add_child(degree_element)
      return etd_ms_root