Delete MessageStartEvent node, but the bpmn:Message element is still exist

The messageEventDefinition contains a property messageRef to reference a message element as below.

    <bpmn2:startEvent id="Event_1mjq7q5" sf:guid="d5a54f51-e7c9-4929-9818-17b75ae46882" name="Start">
      <bpmn2:outgoing>Flow_0e36inl</bpmn2:outgoing>
      <bpmn2:messageEventDefinition id="MessageEventDefinition_0ambvku" messageRef="Message_CS0UYB" />
    </bpmn2:startEvent>

The messageRef references a message element:

  <bpmn2:message id="Message_CS0UYB" name="iugiugiug" />

After deleted messageStartEvent node on the diagram canvas, the bpmn:Message element still exist in the xml document. The message object is created by the bpmnFactory code in the set method when updating property.

const setValue = value => {
    const businessObject = getBusinessObject(element);
    var definitions = businessObject.$parent.$parent;
    var rootElements = definitions.rootElements;

    if (businessObject.eventDefinitions) {
        var messageEventDefinition = businessObject.eventDefinitions[0];
        var messageRef = messageEventDefinition.messageRef;

        var msg;
        if (messageRef) {
            msg = FindMessageById(definitions, messageRef.id);
        }

        //set message value
        if (msg) {
            msg.name = value;
        } else {
            msg = bpmnFactory.create("bpmn:Message");
            msg.id = "Message_" + jshelper.getRandomString(6);
            msg.name = value;
            rootElements.push(msg);
        }
        messageEventDefinition.messageRef = msg;
    }
}

It seemed that I need to manually write code to delete it? Is there any better ideas to impletment this feature? Thanks