boolean (@NotNull PsiExpression condition, @Nullable PsiStatement branch) { while (true) { if (branch == null || ControlFlowUtils.statementIsEmpty(branch)) return true; if (!(ControlFlowUtils.stripBraces(branch) instanceof PsiIfStatement ifStatement)) return false; PsiExpression nextCondition = ifStatement.getCondition(); if (nextCondition == null) return false; PsiStatement elseBranch = ifStatement.getElseBranch(); if (!DfaPsiUtil.mutuallyExclusive(condition, nextCondition)) return false; branch = elseBranch; } }