docs: public void restoreProcessInstance(Collection<ExecutionEntity> executions,
        Collection<EventSubscriptionEntity> eventSubscriptions,
        Collection<VariableInstanceEntity> variables,
        Collection<TaskEntity> tasks,
        Collection<JobEntity> jobs,
        Collection<IncidentEntity> incidents,
        Collection<ExternalTaskEntity> externalTasks) {
  
      if(!isProcessInstanceExecution()) {
        throw LOG.restoreProcessInstanceException(this);
      }
  
      // index executions by id
      Map<String, ExecutionEntity> executionsMap = new HashMap<>();
      for (ExecutionEntity execution : executions) {
        executionsMap.put(execution.getId(), execution);
      }
  
      Map<String, List<VariableInstanceEntity>> variablesByScope = new HashMap<>();
      if(variables != null) {
        for (VariableInstanceEntity variable : variables) {
          CollectionUtil.addToMapOfLists(variablesByScope, variable.getVariableScopeId(), variable);
        }
      }
  
      // restore execution tree
      for (ExecutionEntity execution : executions) {
        if (execution.executions == null) {
          execution.executions = new ArrayList<>();
        }
        if(execution.eventSubscriptions == null && eventSubscriptions != null) {
          execution.eventSubscriptions = new ArrayList<>();
        }
        if(variables != null) {
          execution.variableStore.setVariablesProvider(
              new VariableCollectionProvider<>(variablesByScope.get(execution.id)));
        }
        String parentId = execution.getParentId();
        ExecutionEntity parent = executionsMap.get(parentId);
        if (!execution.isProcessInstanceExecution()) {
          if (parent == null) {
            throw LOG.resolveParentOfExecutionFailedException(parentId, execution.getId());
          }
          execution.processInstance = this;
          execution.parent = parent;
          if (parent.executions == null) {
            parent.executions = new ArrayList<>();
          }
          parent.executions.add(execution);
        } else {
          execution.processInstance = execution;
        }
      }
  
      if(eventSubscriptions != null) {
        // add event subscriptions to the right executions in the tree
        for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
          ExecutionEntity executionEntity = executionsMap.get(eventSubscription.getExecutionId());
          if (executionEntity != null) {
            executionEntity.addEventSubscription(eventSubscription);
          }
          else {
            throw LOG.executionNotFoundException(eventSubscription.getExecutionId());
          }
        }
      }
  
      if (jobs != null) {
        for (JobEntity job : jobs) {
          ExecutionEntity execution = executionsMap.get(job.getExecutionId());
          job.setExecution(execution);
        }
      }
  
      if (tasks != null) {
        for (TaskEntity task : tasks) {
          ExecutionEntity execution = executionsMap.get(task.getExecutionId());
          task.setExecution(execution);
          execution.addTask(task);
  
          if(variables != null) {
            task.variableStore.setVariablesProvider(new VariableCollectionProvider<>(variablesByScope.get(task.id)));
          }
        }
      }
  
  
      if (incidents != null) {
        for (IncidentEntity incident : incidents) {
          ExecutionEntity execution = executionsMap.get(incident.getExecutionId());
          incident.setExecution(execution);
        }
      }
  
      if (externalTasks != null) {
        for (ExternalTaskEntity externalTask : externalTasks) {
          ExecutionEntity execution = executionsMap.get(externalTask.getExecutionId());
          externalTask.setExecution(execution);
          execution.addExternalTask(externalTask);
        }
      }
    }