code: @Override
    public PvmExecutionImpl findExecutionForFlowScope(PvmScope targetFlowScope) {
      // if this execution is not a scope execution, use the parent
      final PvmExecutionImpl scopeExecution = isScope() ? this : getParent();
  
      ScopeImpl currentActivity = getActivity();
      EnsureUtil.ensureNotNull("activity of current execution", currentActivity);
  
      // if this is a scope execution currently executing a non scope activity
      currentActivity = currentActivity.isScope() ? currentActivity : currentActivity.getFlowScope();
  
      return scopeExecution.findExecutionForScope(currentActivity, (ScopeImpl) targetFlowScope);
    }
docs: For a given target flow scope, this method returns the corresponding scope execution.
  <p>
  Precondition: the execution is active and executing an activity.
  Can be invoked for scope and non scope executions.
  
  @param targetFlowScope scope activity or process definition for which the scope execution should be found
  @return the scope execution for the provided targetFlowScope