OptionalToIfContext (@NotNull PsiExpression chainExpression) { PsiStatement chainStatement = PsiTreeUtil.getParentOfType(chainExpression, PsiStatement.class); if (chainStatement == null) return null; ChainExpressionModel model = ChainExpressionModel.create(chainStatement, chainExpression); if (model == null) return null; return new OptionalToIfContext(chainExpression, model); }