private static @Nullable PsiLocalVariable findCastedLocalVariable(PsiTypeCastExpression castExpression) {
    PsiLocalVariable variable = PsiTreeUtil.getParentOfType(castExpression, PsiLocalVariable.class);
    if (variable == null) return null;
    PsiExpression initializer = PsiUtil.skipParenthesizedExprDown(variable.getInitializer());
    if (initializer != castExpression) return null;
    PsiElement scope = PsiUtil.getVariableCodeBlock(variable, null);
    if (scope == null) return null;
    if (!HighlightControlFlowUtil.isEffectivelyFinal(variable, scope, null)) return null;
    return variable;
  }
private static @Nullable PsiLocalVariable findCastedLocalVariable(PsiTypeCastExpression castExpression)