Consolidate TreeNode transform and rewrite APIs
#8891
Merged
TreeNode transform and rewrite APIs
#8891