Example implementation follows pseudocode from "An intoductory tutorial on kd-trees" by Andrew W. Moore, Carnegie Mellon University, PDF accessed from http://www.autonlab.org/autonweb/14665
The code here passes some simple tests but has not been well tested or used for any real tasks.
Pivot choice is median obtained by sorting, leaving tree construction time asymptotically slow. There is no support for modifying the tree after construction. It's just a simple demonstration.