private static PsiClassType toClassType(PsiType type) {
    if (type instanceof PsiClassType) {
      return (PsiClassType)type;
    }
    if (type instanceof PsiCapturedWildcardType) {
      return toClassType(((PsiCapturedWildcardType)type).getUpperBound());
    }
    if (type instanceof PsiWildcardType) {
      return toClassType(((PsiWildcardType)type).getBound());
    }
    return null;
  }
private static PsiClassType toClassType(PsiType type)