Added a const version of findNearestCommonDominator