public static @NotNull DfaValue getArrayElementValue(@NotNull DfaValueFactory factory,
                                                       @Nullable DfaValue array,
                                                       @NotNull LongRangeSet indexSet) {
    if (array instanceof DfaTypeValue) {
      PsiVariable var = array.getDfType().getConstantOfType(PsiVariable.class);
      if (var != null) {
        array = new PlainDescriptor(var).createValue(factory, null);
      }
    }
    if (!(array instanceof DfaVariableValue arrayDfaVar)) return factory.getUnknown();
    if (indexSet.isEmpty()) return factory.getUnknown();
    long min = indexSet.min();
    long max = indexSet.max();
    if (min == max && min >= 0 && min < Integer.MAX_VALUE) {
      DfaValue value = getArrayElementValue(factory, array, (int)min);
      return value == null ? factory.getUnknown() : value;
    }
    PsiVariable arrayPsiVar = ObjectUtils.tryCast(arrayDfaVar.getPsiVariable(), PsiVariable.class);
    if (arrayPsiVar == null) return factory.getUnknown();
    DfType arrayType = arrayDfaVar.getDfType();
    DfType targetType = TypeConstraint.fromDfType(arrayType).getArrayComponentType();
    PsiExpression[] elements = ExpressionUtils.getConstantArrayElements(arrayPsiVar);
    if (elements == null || elements.length == 0) return factory.getUnknown();
    indexSet = indexSet.meet(LongRangeSet.range(0, elements.length - 1));
    if (indexSet.isEmpty() || indexSet.isCardinalityBigger(100)) return factory.getUnknown();
    return LongStreamEx.of(indexSet.stream())
      .mapToObj(idx -> getAdvancedExpressionDfaValue(factory, elements[(int)idx], targetType))
      .prefix(DfaValue::unite)
      .takeWhileInclusive(value -> !DfaTypeValue.isUnknown(value))
      .reduce((a, b) -> b)
      .orElseGet(factory::getUnknown);
  }
public static @NotNull DfaValue getArrayElementValue(@NotNull DfaValueFactory factory,
                                                       @Nullable DfaValue array,
                                                       @NotNull LongRangeSet indexSet)