code: @SuppressWarnings("unchecked")
      public <S extends Scope> Set<S> getScopesByType(Class<S> scopeType) {
          Set<S> typedScopes = new HashSet<>();
          for (Scope scope : getScopes()) {
              if (scopeType.isInstance(scope)) {
                  typedScopes.add((S) scope);
              }
          }
          return typedScopes;
      }
docs: Filters the scopes corresponding to a type
  
  @param <S>       the type of the scope to filter.
  @param scopeType the type of scope
  @return the scopes of the given type