correct merging implementation, now with predicates for commands
even better merging
began work on for-each-depth-first