It's not surprising the code is a little longer because the new API includes support for infinitely more complex sets of restrictions...
That said, I don't think the way you've done it is quite 'perfect'. The question here is, are you doing this only on newly-created activities (so you know for sure that yours are the only conditions) - if so then you can make the code simpler. If not then the approach above will work, but doing it perfectly would be more complex still, unless I've misunderstood something.
To explain why: your code works by creating a new root tree, with the existing tree as one branch, and a new condition as the other branch. This works in general but (for good reasons too complex to explain here) the 'show' options are only available at the root level, which might cause a change in behaviour. The perfect logic would be:
a) If the top-level condition is currently AND or NOT OR, then add your condition (or a negative version of it) directly to the existing top-level tree.
b) If the top-level condition is currently OR or NOT AND, then do it like you have done (making sure to correctly transfer the show option to the subtree).
(Also just to note - after doing any of this then you need to rebuild course cache.)
It would be possible to add PHP functions to incorporate some of this logic, i.e. when you want to add an AND condition to the root level of a tree, which is probably the most common case of a programmatic modification. This wasn't implemented already because nothing in Moodle core needs it (the previous API was needed by Moodle core) and it is possible to achieve by manually manipulating the JSON array, as you have.
--sam