docs: def cleanup_nodes(doc):
      """
      Remove text nodes containing only whitespace
      """
      for node in doc.documentElement.childNodes:
          if node.nodeType == Node.TEXT_NODE and node.nodeValue.isspace():
              doc.documentElement.removeChild(node)
      return doc