private static boolean needToDeclareFinal(PsiExpression[] occurrences) {
    PsiElement scopeToDeclare = null;
    for (PsiExpression occurrence : occurrences) {
      final PsiElement data = occurrence.getUserData(ElementToWorkOn.PARENT);
      PsiElement element = data != null ? data : occurrence;
      if (scopeToDeclare == null) {
        scopeToDeclare = element;
      }
      else {
        scopeToDeclare = PsiTreeUtil.findCommonParent(scopeToDeclare, element);
      }
      if (PsiTreeUtil.getParentOfType(element, PsiSwitchLabelStatement.class, true, PsiStatement.class) != null) {
        return true;
      }
    }
    if(scopeToDeclare == null) {
      return false;
    }

    for (PsiExpression occurrence : occurrences) {
      PsiElement parent = BaseExpressionToFieldHandler.getPhysicalElement(occurrence);
      while (parent != null && !parent.equals(scopeToDeclare)) {
        parent = parent.getParent();
        if (parent instanceof PsiClass) {
          return !PsiUtil.isLanguageLevel8OrHigher(parent);
        }
      }
    }
    return false;
  }
private static boolean needToDeclareFinal(PsiExpression[] occurrences)