deduplicate tuple tree creation code

Previously tuple -> tree representation has been implemented in
three place: tree builder, tree gen, build utils. Now it's just
defined once in tree gen.
for loop pr preparations