public KDNode FindNearestPoint(Point2D x) { if (Root == null) { return(null); } checkedNodesNum = 0; KDNode parent = Root.FindParent(x); nearestPoint = parent; minDistanceValue = Root.Distance(x, parent.x, 2); if (parent.Equal(x, parent.x, 2) == true) { return(nearestPoint); } SearchParent(parent, x); Uncheck(); return(nearestPoint); }