def _merge_element_contents(el):
 parent = el.getparent()
 text = (el.text or '')
 if el.tail:
  if (not len(el)):
   text += el.tail
  elif el[(-1)].tail:
   el[(-1)].tail += el.tail
  else:
   el[(-1)].tail = el.tail
 index = parent.index(el)
 if text:
  if (index == 0):
   previous = None
  else:
   previous = parent[(index - 1)]
  if (previous is None):
   if parent.text:
    parent.text += text
   else:
    parent.text = text
  elif previous.tail:
   previous.tail += text
  else:
   previous.tail = text
 parent[index:(index + 1)] = el.getchildren()

def _merge_element_contents ( el ) : parent = el . getparent ( ) text = ( el . text or '' ) if el . tail : if ( not len ( el ) ) : text += el . tail elif el [ ( - 1 ) ] . tail : el [ ( - 1 ) ] . tail += el . tail else : el [ ( - 1 ) ] . tail = el . tail index = parent . index ( el ) if text : if ( index == 0 ) : previous = None else : previous = parent [ ( index - 1 ) ] if ( previous is None ) : if parent . text : parent . text += text else : parent . text = text elif previous . tail : previous . tail += text else : previous . tail = text parent [ index : ( index + 1 ) ] = el . getchildren ( )
removes an element .