[MRG +1] simpler memory management for trees

This simplifies some of the `realloc` usage in the tree code. I haven't looked at the other modules besides `_tree.pyx` yet. Ping @arjoly @glouppe.