javascript simulation of trees