k-d tree implementation in python