TREE .BST .Can someone help in optimizing the code

Here is the question. I think i have have missed some of the test case , Please help figuring them out.

My Algorithm

  1. Consider only that point which are closest to the current point.
  2. Do this with every point.
  3. Store this in a list .
  4. Print the list.

Here is the code.