code for tree