PsiBlockStatement (PsiIfStatement ifStatement, boolean inThen) { if (inThen) { PsiStatement elseBranch = ifStatement.getElseBranch(); if (elseBranch == null) { ifStatement.setElseBranch(BlockUtils.createBlockStatement(myProject)); return (PsiBlockStatement)ifStatement.getElseBranch(); } if (!(elseBranch instanceof PsiBlockStatement)) { return (PsiBlockStatement)BlockUtils.expandSingleStatementToBlockStatement(elseBranch).getParent().getParent(); } return (PsiBlockStatement)elseBranch; } else { PsiStatement thenBranch = ifStatement.getThenBranch(); if (thenBranch == null) { ifStatement.setThenBranch(BlockUtils.createBlockStatement(myProject)); return (PsiBlockStatement)ifStatement.getThenBranch(); } if (!(thenBranch instanceof PsiBlockStatement)) { return (PsiBlockStatement)BlockUtils.expandSingleStatementToBlockStatement(thenBranch).getParent().getParent(); } return (PsiBlockStatement)thenBranch; } }