private static List<PsiEnumConstant> findUnusedConstants(GrSwitchStatement switchStatement) {
    final GrExpression condition = switchStatement.getCondition();
    if (condition == null) return Collections.emptyList();

    final PsiType type = condition.getType();
    if (!(type instanceof PsiClassType)) return Collections.emptyList();

    final PsiClass resolved = ((PsiClassType)type).resolve();
    if (resolved == null || !resolved.isEnum()) return Collections.emptyList();

    final PsiField[] fields = resolved.getFields();
    final List<PsiEnumConstant> constants = new ArrayList<>(ContainerUtil.findAll(fields, PsiEnumConstant.class));

    final GrCaseSection[] sections = switchStatement.getCaseSections();
    for (GrCaseSection section : sections) {
      for (GrExpression value : section.getExpressions()) {
        if (value instanceof GrReferenceExpression) {
          final PsiElement r = ((GrReferenceExpression)value).resolve();
          constants.remove(r);
        }
      }
    }
    return constants;
  }
private static List<PsiEnumConstant> findUnusedConstants(GrSwitchStatement switchStatement)