void (@NotNull List<PsiReferenceExpression> references, @NotNull PsiPatternVariable variable, @NotNull PsiInstanceOfExpression psiInstanceOfExpression) { PsiIfStatement ifStatement = PsiTreeUtil.getParentOfType(psiInstanceOfExpression, PsiIfStatement.class); if (ifStatement != null && PsiTreeUtil.isAncestor(ifStatement.getCondition(), psiInstanceOfExpression, false)) { processReferencesForIfStatement(ifStatement, variable, psiInstanceOfExpression, references); return; } PsiConditionalLoopStatement conditionalLoopStatement = PsiTreeUtil.getParentOfType(psiInstanceOfExpression, PsiConditionalLoopStatement.class); if (conditionalLoopStatement != null && PsiTreeUtil.isAncestor(conditionalLoopStatement.getCondition(), psiInstanceOfExpression, false)) { processReferencesForLoopStatement(conditionalLoopStatement, variable, psiInstanceOfExpression, references); return; } replaceWithCast(variable, references); }