Optimal decision tree synthesis for efficient neighborhood computation