JavaScript k-d Tree Implementation