R-tree clean-ups

This PR refactors the R-tree code to be more consistent with the rest of the codebase.

There is still some refactoring required, notably to avoid the ugly manipulation of `arguments` in `remove`. This will follow in a separate PR (unless somebody else wants to do it).