codecov-io: ## [Current coverage][cc-pull] is **90.83%**
> Merging [#259][cc-pull] into [master][cc-base-branch] will increase coverage by **<.01%**

```diff
@@             master       #259   diff @@
==========================================
  Files            51         51          
  Lines          6836       6840     +4   
  Methods           0          0          
  Messages          0          0          
  Branches       1312       1312          
==========================================
+ Hits           6209       6213     +4   
  Misses          468        468          
  Partials        159        159          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last updated by [2d37673...cbc1b34][cc-compare]
[cc-base-branch]: https://codecov.io/gh/html5lib/html5lib-python/branch/master?src=pr
[cc-compare]: https://codecov.io/gh/html5lib/html5lib-python/compare/2d376737a6246ebb38a79600a7fe75abd923cf3e...cbc1b34806178bd5119464865c263c0e254cfa55
[cc-pull]: https://codecov.io/gh/html5lib/html5lib-python/pull/259?src=pr
diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py
index d394148..4d12bd4 100644
--- a/html5lib/treebuilders/etree.py
+++ b/html5lib/treebuilders/etree.py
@@ -100,6 +100,7 @@ def getETreeBuilder(ElementTreeImplementation, fullTree=False):
             node.parent = self
 
         def removeChild(self, node):
+            self._childNodes.remove(node)
             self._element.remove(node._element)
             node.parent = None
 

etree treewalker infinite loop
This goes into an infinite loop:

```python
import html5lib

frag = html5lib.parseFragment("<b><em><foo><foob><fooc><aside></b></em>")

walker = html5lib.getTreeWalker("etree")

print list(walker(frag))
```
diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py
index 0ec5b04..b7a92fd 100644
--- a/html5lib/tests/test_parser2.py
+++ b/html5lib/tests/test_parser2.py
@@ -7,7 +7,7 @@ import io
 from . import support  # noqa
 
 from html5lib.constants import namespaces
-from html5lib import parse, HTMLParser
+from html5lib import parse, parseFragment, HTMLParser
 
 
 # tests that aren't autogenerated from text files
@@ -88,3 +88,8 @@ def test_debug_log():
             expected[i] = tuple(log)
 
     assert parser.log == expected
+
+
+def test_no_duplicate_clone():
+    frag = parseFragment("<b><em><foo><foob><fooc><aside></b></em>")
+    assert len(frag) == 2

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest mock
git submodule update --init --recursive
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
chardet==5.2.0
datrie==0.8.2
exceptiongroup==1.2.2
Genshi==0.7.9
-e git+https://github.com/html5lib/html5lib-python.git@2d376737a6246ebb38a79600a7fe75abd923cf3e#egg=html5lib
iniconfig==2.1.0
lxml==5.3.1
mock==5.2.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
six==1.17.0
tomli==2.2.1
webencodings==0.5.1

name: html5lib-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - chardet==5.2.0
      - datrie==0.8.2
      - exceptiongroup==1.2.2
      - genshi==0.7.9
      - iniconfig==2.1.0
      - lxml==5.3.1
      - mock==5.2.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - six==1.17.0
      - tomli==2.2.1
      - webencodings==0.5.1
prefix: /opt/conda/envs/html5lib-python

html5lib/tests/test_parser2.py::test_no_duplicate_clone
html5lib/tests/test_parser2.py::test_assertDoctypeCloneable html5lib/tests/test_parser2.py::test_line_counter html5lib/tests/test_parser2.py::test_namespace_html_elements_0_dom html5lib/tests/test_parser2.py::test_namespace_html_elements_1_dom html5lib/tests/test_parser2.py::test_namespace_html_elements_0_etree html5lib/tests/test_parser2.py::test_namespace_html_elements_1_etree html5lib/tests/test_parser2.py::test_unicode_file html5lib/tests/test_parser2.py::test_duplicate_attribute html5lib/tests/test_parser2.py::test_debug_log
html5lib/treebuilders/etree.py
html5lib/treebuilders/etree.py