_Element.clear() takes a boolean parameter named  keep_tail.
This parameter does not exist in the stdlib ElementTree, but does exist in lxml.etree.
See https://lxml.de/api/lxml.etree._Element-class.html#clear
The docstring for clear in lxml.etree reads
Resets an element.  This function removes all subelements, clears
all attributes and sets the text and tail properties to None.
Pass ``keep_tail=True`` to leave the tail text untouched.