<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_element(self, name, traversal_parent=False, reference=None):
 """ Create an element having the given name :type name: ``str`` :param name: the name of the element to be created (e.g. PID) :type traversal_parent: ``bool`` :param traversal_parent: if ``True``, the parent will be set as temporary for traversal purposes :param reference: the new element structure (see :func:`load_reference <hl7apy.load_reference>`) :return: an instance of an :class:`hl7apy.core.Element` subclass :raises: :exc:`ChildNotFound <hl7apy.exceptions.ChildNotFound>` if the element does not exist """

        if reference is None:
            reference = self.element.find_child_reference(name)
        if reference is not None:
            cls = reference['cls']
            element_name = reference['name']
            kwargs = {'reference': reference['ref'],
                      'validation_level': self.element.validation_level,
                      'version': self.element.version}
            if not traversal_parent:
                kwargs['parent'] = self.element
            else:
                kwargs['traversal_parent'] = self.element
            return cls(element_name, **kwargs)
        else:
            raise ChildNotFound(name)