boolean (PsiElement element) { if (!(element instanceof PsiJavaToken token)) { return false; } final PsiElement parent = token.getParent(); if (!(parent instanceof PsiIfStatement ifStatement)) { return false; } final PsiStatement thenBranch = ifStatement.getThenBranch(); final PsiStatement elseBranch = ifStatement.getElseBranch(); if (thenBranch == null) { return false; } if (elseBranch == null) { return false; } if (!(elseBranch instanceof PsiIfStatement childIfStatement)) { return false; } if (ErrorUtil.containsError(ifStatement)) { return false; } final PsiStatement childThenBranch = childIfStatement.getThenBranch(); return EquivalenceChecker.getCanonicalPsiEquivalence().statementsAreEquivalent(thenBranch, childThenBranch); }