[WIP] fix MSVC build in neighbors and tree

Some parts of the new neighbors code doesn't build under MSVC.
Also the tree module.

If anybody knows a better way to do this, please help.