[refactor] abstact and text the tree builder, this also introduces text/tag density