def add_default_fields(elem, default_fields):
 for field in default_fields.get(elem.tag, []):
  if (elem.find(field) is None):
   SubElement(elem, field)
 for child in elem:
  add_default_fields(child, default_fields)

def add_default_fields ( elem , default_fields ) : for field in default_fields . get ( elem . tag , [ ] ) : if ( elem . find ( field ) is None ) : SubElement ( elem , field ) for child in elem : add_default_fields ( child , default_fields )
add blank elements and subelements specified in default_fields .