shortened tree.js code