presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java/Analyzer/isReachable
class Analyzer:        private boolean isReachable(ATNState target, RuleStartState from)
        {
            Deque<ATNState> activeStates = new ArrayDeque<>();
            activeStates.add(from);

            while (!activeStates.isEmpty()) {
                ATNState current = activeStates.pop();

                if (current.stateNumber == target.stateNumber) {
                    return true;
                }

                for (int i = 0; i < current.getNumberOfTransitions(); i++) {
                    Transition transition = current.transition(i);

                    if (transition.isEpsilon()) {
                        activeStates.push(transition.target);
                    }
                }
            }

            return false;
        }