@NotNull
  public static List<? extends PsiClassType> getClassTypeComponents(PsiType type) {
    if (type instanceof PsiClassType) return Collections.singletonList((PsiClassType)type);
    if (type instanceof PsiCapturedWildcardType) {
      return getClassTypeComponents(((PsiCapturedWildcardType)type).getUpperBound());
    }
    if (type instanceof PsiIntersectionType) {
      List<PsiClassType> classTypes = new ArrayList<>();
      for (PsiType conjunct : ((PsiIntersectionType)type).getConjuncts()) {
        classTypes.addAll(getClassTypeComponents(conjunct));
      }
      return classTypes;
    }
    return Collections.emptyList();
  }
@NotNull
  public static List<? extends PsiClassType> getClassTypeComponents(PsiType type)