some refactoring on categorical node rebuilding, hopefully fix freezing issue

[#74295478]
Merge pull request #41 from sanity/debug-quickdt-freezing-occasionally-74295478

some refactoring on categorical node rebuilding, hopefully fix freezing ...