Comparator and recursive methods.