docs: protected Map<ScopeImpl, PvmExecutionImpl> createActivityExecutionMapping(ScopeImpl currentScope,
                                                                              final Map<ScopeImpl, PvmExecutionImpl> mapping) {
      if (!isScope()) {
        throw new ProcessEngineException("Execution must be a scope execution");
      }
      if (!currentScope.isScope()) {
        throw new ProcessEngineException("Current scope must be a scope.");
      }
  
      // collect all ancestor scope executions unless one is encountered that is already in "mapping"
      ScopeExecutionCollector scopeExecutionCollector = new ScopeExecutionCollector();
      new ExecutionWalker(this)
        .addPreVisitor(scopeExecutionCollector)
        .walkWhile(new ReferenceWalker.WalkCondition<PvmExecutionImpl>() {
          public boolean isFulfilled(PvmExecutionImpl element) {
            return element == null || mapping.containsValue(element);
          }
        });
      final List<PvmExecutionImpl> scopeExecutions = scopeExecutionCollector.getScopeExecutions();
  
      // collect all ancestor scopes unless one is encountered that is already in "mapping"
      ScopeCollector scopeCollector = new ScopeCollector();
      new FlowScopeWalker(currentScope)
        .addPreVisitor(scopeCollector)
        .walkWhile(new ReferenceWalker.WalkCondition<ScopeImpl>() {
          public boolean isFulfilled(ScopeImpl element) {
            return element == null || mapping.containsKey(element);
          }
        });
  
      final List<ScopeImpl> scopes = scopeCollector.getScopes();
  
      // add all ancestor scopes and scopeExecutions that are already in "mapping"
      // and correspond to ancestors of the topmost previously collected scope
      ScopeImpl topMostScope = scopes.get(scopes.size() - 1);
      new FlowScopeWalker(topMostScope.getFlowScope())
        .addPreVisitor(new TreeVisitor<ScopeImpl>() {
          public void visit(ScopeImpl obj) {
            scopes.add(obj);
            PvmExecutionImpl priorMappingExecution = mapping.get(obj);
  
            if (priorMappingExecution != null && !scopeExecutions.contains(priorMappingExecution)) {
              scopeExecutions.add(priorMappingExecution);
            }
          }
        })
        .walkWhile();
  
      if (scopes.size() == scopeExecutions.size()) {
        // the trees are in sync
        Map<ScopeImpl, PvmExecutionImpl> result = new HashMap<>();
        for (int i = 0; i < scopes.size(); i++) {
          result.put(scopes.get(i), scopeExecutions.get(i));
        }
        return result;
      } else {
        // Wounderful! The trees are out of sync. This is due to legacy behavior
        return LegacyBehavior.createActivityExecutionMapping(scopeExecutions, scopes);
      }
    }