code: protected ExecutionEntity findFirstParentScopeExecution(ExecutionEntity executionEntity) {
      ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
      ExecutionEntity parentScopeExecution = null;
      ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(executionEntity.getParentId());
      while (currentlyExaminedExecution != null && parentScopeExecution == null) {
        if (currentlyExaminedExecution.isScope()) {
          parentScopeExecution = currentlyExaminedExecution;
        } else {
          currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId());
        }
      }
      return parentScopeExecution;
    }
docs: Returns the first parent execution of the provided execution that is a scope.