@NotNull
  private static PsiType normalizeType(@NotNull PsiType psiType) {
    if (psiType instanceof PsiArrayType) {
      PsiType normalized = normalizeType(psiType.getDeepComponentType());
      int dimensions = psiType.getArrayDimensions();
      if (normalized instanceof PsiIntersectionType) {
        PsiType[] types = ContainerUtil.map2Array(((PsiIntersectionType)normalized).getConjuncts(), PsiType.EMPTY_ARRAY, t -> PsiTypesUtil.createArrayType(t, dimensions));
        return PsiIntersectionType.createIntersection(true, types);
      }
      return PsiTypesUtil.createArrayType(normalized, dimensions);
    }
    if (psiType instanceof PsiWildcardType wildcardType) {
      return normalizeType(wildcardType.getExtendsBound());
    }
    if (psiType instanceof PsiCapturedWildcardType wildcardType) {
      return normalizeType(wildcardType.getUpperBound());
    }
    if (psiType instanceof PsiIntersectionType intersectionType) {
      PsiType[] types = ContainerUtil.map2Array(intersectionType.getConjuncts(), PsiType.EMPTY_ARRAY, TypeConstraints::normalizeType);
      if (types.length > 0) {
        return PsiIntersectionType.createIntersection(true, types);
      }
    }
    if (psiType instanceof PsiClassType classType) {
      return normalizeClassType(classType, new HashSet<>());
    }
    return psiType;
  }
@NotNull
  private static PsiType normalizeType(@NotNull PsiType psiType)