Finding the minimum and maximum nodes