diff --git a/tools/python/jwutils/stree/StringTree.py b/tools/python/jwutils/stree/StringTree.py index 9e66cbf..64e46e9 100644 --- a/tools/python/jwutils/stree/StringTree.py +++ b/tools/python/jwutils/stree/StringTree.py @@ -104,8 +104,13 @@ class StringTree: # export if l > 1: assert len(rest) > 0 return self.children[nibble].__set(rest, content=content) + # last component, a.k.a. leaf if content is not None: gc = content if isinstance(content, StringTree) else StringTree('', content=content) + # Make sure no existing grand child is updated. It would reside too + # far up in the grand child OrderedDict, we need it last + if gc.content in self.children[nibble].children: + del self.children[nibble].children[gc.content] self.children[nibble].children[gc.content] = gc return self.children[nibble]