code: protected static ActivityImpl getEventScopeCompensationHandler(ExecutionEntity execution) {
      ActivityImpl activity = execution.getActivity();
  
      ActivityImpl compensationHandler = activity.findCompensationHandler();
      if (compensationHandler != null && compensationHandler.isSubProcessScope()) {
        // subprocess with inner compensation event subprocess
        return compensationHandler;
      } else {
        // subprocess without compensation handler or
        // multi instance activity
        return activity;
      }
    }
docs: In the context when an event scope execution is created (i.e. a scope such as a subprocess has completed),
  this method returns the compensation handler activity that is going to be executed when by the event scope execution.
  
  This method is not relevant when the scope has a boundary compensation handler.