presto-main/src/main/java/io/prestosql/sql/planner/iterative/RuleIndex.java/RuleIndex/getFirstPattern
class RuleIndex:        private Pattern<?> getFirstPattern(Pattern<?> pattern)
        {
            while (pattern.previous().isPresent()) {
                pattern = pattern.previous().get();
            }
            return pattern;
        }