Implement last_index_of function
Add add_tree implementation