presto-main/src/main/java/io/prestosql/sql/analyzer/Scope.java/Scope/findLocally
class Scope:    private Optional<Scope> findLocally(Predicate<Scope> match)
    {
        Scope scope = this;

        do {
            if (match.test(scope)) {
                return Optional.of(scope);
            }

            Optional<Scope> parent = scope.getLocalParent();
            if (!parent.isPresent()) {
                break;
            }

            scope = parent.get();
        }
        while (true);

        return Optional.empty();
    }