code: static <S extends ScopeType<S>> boolean isScopeAncestor(ScopeWrapper<S> scope, ScopeWrapper<S> possibleAncestor) {
      Queue<ScopeWrapper<S>> ancestors = new LinkedList<>();
      ancestors.add(scope);
      while (true) {
        if (ancestors.isEmpty()) {
          return false;
        }
        if (ancestors.peek().equals(possibleAncestor)) {
          return true;
        }
        ancestors.addAll(ancestors.poll().getParentScopes());
      }
    }
docs: Determine if a {@link ScopeWrapper} is an ancestor of another {@link ScopeWrapper}.