DEV: ensures tree is present for traverseCustomWidgets (PR #13855)

We already had this check sometimes in code, it’s just safer to have this responsibility baked in the function.

GitHub