Add K-d tree.

Implements http://rosettacode.org/wiki/K-d_tree.