revamped code to allow the tree constructor to be called without a canvas, which can then be set later by calling tree.init()