ChainReturn (@NotNull PsiReturnStatement chainReturn, @NotNull PsiExpression chainExpression) { if (PsiUtil.skipParenthesizedExprDown(chainReturn.getReturnValue()) != chainExpression) return null; Object mark = new Object(); PsiTreeUtil.mark(chainExpression, mark); PsiReturnStatement chainReturnCopy = tryCast(chainReturn.copy(), PsiReturnStatement.class); if (chainReturnCopy == null) return null; PsiExpression chainExpressionCopy = tryCast(PsiTreeUtil.releaseMark(chainReturnCopy, mark), PsiExpression.class); if (chainExpressionCopy == null) return null; return new ChainReturn(chainReturnCopy, chainExpressionCopy); }