code: public void replace(PvmExecutionImpl execution) {
      // activity instance id handling
      this.activityInstanceId = execution.getActivityInstanceId();
      this.isActive = execution.isActive;
  
      this.replacedBy = null;
      execution.replacedBy = this;
  
      this.transitionsToTake = execution.transitionsToTake;
  
      execution.leaveActivityInstance();
    }
docs: <p>Replace an execution by this execution. The replaced execution has a pointer ({@link #getReplacedBy()}) to this execution.
  This pointer is maintained until the replaced execution is removed or this execution is removed/ended.</p>
  <p>
  <p>This is used for two cases: Execution tree expansion and execution tree compaction</p>
  <ul>
  <li><b>expansion</b>: Before:
  <pre>
  -------
  |  e1 |  scope
  -------
  </pre>
  After:
  <pre>
  -------
  |  e1 |  scope
  -------
  |
  -------
  |  e2 |  cc (no scope)
  -------
  </pre>
  e2 replaces e1: it should receive all entities associated with the activity currently executed
  by e1; these are tasks, (local) variables, jobs (specific for the activity, not the scope)
  </li>
  <li><b>compaction</b>: Before:
  <pre>
  -------
  |  e1 |  scope
  -------
  |
  -------
  |  e2 |  cc (no scope)
  -------
  </pre>
  After:
  <pre>
  -------
  |  e1 |  scope
  -------
  </pre>
  e1 replaces e2: it should receive all entities associated with the activity currently executed
  by e2; these are tasks, (all) variables, all jobs
  </li>
  </ul>
  
  @see #createConcurrentExecution()
  @see #tryPruneLastConcurrentChild()