@SuppressWarnings("unchecked")
  private static @Nullable <T extends SemElement> List<T> findCached(@NotNull State state,
                                                                     @NotNull SemKey<T> key,
                                                                     @NotNull IntObjectMap<List<SemElement>> chunk) {
    List<T> singleList = null;
    LinkedHashSet<T> result = null;

    Collection<SemKey<?>> inheritors = state.inheritors.getOrDefault(key, emptyList());
    for (var inheritor : inheritors) {
      List<T> cached = (List<T>)getSemElements(chunk, inheritor);
      if (cached == null) {
        return null;
      }

      if (cached != Collections.<T>emptyList()) {
        if (singleList == null) {
          singleList = cached;
          continue;
        }

        if (result == null) {
          result = new LinkedHashSet<>(singleList);
        }
        result.addAll(cached);
      }
    }

    if (result == null) {
      if (singleList != null) {
        return singleList;
      }

      return emptyList();
    }

    return List.copyOf(result);
  }
@SuppressWarnings("unchecked")
  private static @Nullable <T extends SemElement> List<T> findCached(@NotNull State state,
                                                                     @NotNull SemKey<T> key,
                                                                     @NotNull IntObjectMap<List<SemElement>> chunk)