Share the implementation of lowerPair() and higherPair() between the different tree implementations.