Widget cleanup on removal

I have a widget and I need to do some cleanup when its containing tiddler is removed from the story. I tried to use removeChildDomNodes, but it seems the ElementWidget wraps all content in the tiddler and it uses Widget’s removeChildDomNodes which just removes that element from the dom (thereby removing all child nodes), and returns. Is there another way to do cleanups?

There is a pending GH PR: add depth first destroy method by buggyj · Pull Request #7233 · Jermolene/TiddlyWiki5 · GitHub – It’s important to also read the history of the “linked” PR which got merged but was removed before release of 5.3.1 because of performance concerns.

Thanks. For my use case (as well as the original) i only need a notification that the dom node was removed. So maybe just notifying child widgets of this is enough (where they would notify their children). I added a comment in the PR as well.