List<PsiIfStatement> (PsiIfStatement ifStatement) { List<PsiIfStatement> ifStatements = new ArrayList<>(); while (ifStatement != null) { ifStatements.add(ifStatement); PsiStatement elseBranch = ifStatement.getElseBranch(); if (elseBranch instanceof PsiIfStatement) { ifStatement = (PsiIfStatement) elseBranch; } else { ifStatement = null; } } return ifStatements; }