The method call: element.removeContent();
does not remove the Element from its parent, but instead it removes all content from the element (makes it empty).
You probably just want to do: element.detach();
instead.... which will remove the Element (and as a result all of its content too) from the document.