private Optional<Scope> findLocally(Predicate<Scope> match) {
    Scope scope = this;

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

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

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

    return Optional.empty();
  }
Starting from this, finds the closest scope which satisfies given predicate, within the query
boundary.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/Scope.java