Change tree to use arrays