space_partition: subspace merging algorithm by Michel.

Barely tested and probably buggy.