find nearest node to the center function