add tree code, but remove as necessary when it becomes clearly redundant