MathType object not getting removed completely

I have a use case where I am trying to delete the mathtype objects from the document. I am using the below code snippet to do the same.

NodeCollection<Node> children1 = para.getChildNodes();
int paraindex = 0;
for (Node child : children1)
{
    {
        if (child.getNodeType() == NodeType.OFFICE_MATH)
        {
            child.remove();
            break;
        }
        paraindex += child.getText().length();
    }
}

The behaviour seems weird. The object is not deleted completely and there is some part of it [square_boxes] left behind. How can I completely remove the object from the document ?

Attaching SS for reference. image.png (8.0 KB)
image (1).png (8.7 KB)

@cacglo Could you please attach your input and output documents here for our reference? We will check the issue and provide you more information. Unfortunately, it is not possible to analyze the problem using screenshots.