Refactor tree_utils.ts

Test: npm run build:all && npm run test:all
Change-Id: I582d7c0df5da93e49efae5a5dad9d38732bd169a
19 files changed