code: def set(self, name, value, index=-1):
          if isinstance(value, ElementProxy):
              value = value[0].to_er7()
          name = name.upper()
          reference = None if name is None else self.element.find_child_reference(name)
          child_ref, child_name = (None, None) if reference is None else (reference['ref'], reference['name'])
          if isinstance(value, basestring):
              child = self.element.parse_child(value, child_name=child_name, reference=child_ref)
          elif isinstance(value, Element):
              child = value
          elif isinstance(value, BaseDataType):
              child = self.create_element(name, False, reference)
              child.value = value
          else:
              raise ChildNotValid(value, child_name)
          if child.name != child_name:
              raise ChildNotValid(value, child_name)
          child_to_remove = self.child_at_index(child_name, index)
          if child_to_remove is None:
              self.append(child)
          else:
              self.replace_child(child_to_remove, child)
          self.element.set_parent_to_traversal()