The Nearest-Neighbor Technique for particle identification