wrote a cleaner simpler tree_model