For processes with a subprocess that contains an event subprocesses, the activity instance tree contains an activity instance for EITHER the subprocess OR the event subprocess but never for both.
Which one exists appears to be more or less random on how executions are returned from the database. Evidence: Asserting the activity instance tree for these cases randomly fails on some databases (postgres on Jenkins)
- make the event subprocess a scope
- fix the activity instance algorithm such that it is at least consistent and does not behave unpredictable (solving problem 2)
Once fixed, make sure to re-add the assertions removed here: https://github.com/camunda/camunda-bpm-platform/commit/242735625c2674846985c4fd42821cb89af234bd