private static PsiStatement[] withLastStatementReplacedWithYield(PsiStatement[] statements, @NotNull PsiExpression expr) {
    PsiStatement[] result = ArrayUtil.copyOf(statements);
    PsiStatement yieldStatement = createYieldStatement(expr);
    result[result.length - 1] = yieldStatement;
    return result;
  }
private static PsiStatement[] withLastStatementReplacedWithYield(PsiStatement[] statements, @NotNull PsiExpression expr)