/**
   * Executes this <code>CompositeBehaviour</code>. This method executes children according to the
   * scheduling policy defined by concrete subclasses that implements the <code>scheduleFirst()
   * </code> and <code>scheduleNext()</code> methods.
   */
  public final void run() {
    if (starting) {
      scheduleFirst();
      starting = false;
    } else {
      if (currentExecuted) {
        scheduleNext(currentDone, currentResult);
      }
    }

    // Get the current child
    Behaviour current = getCurrent();
    currentExecuted = false;
    currentDone = false;
    currentResult = 0;

    if (current != null) {
      if (current.isRunnable()) {
        // Execute the current child
        current.actionWrapper();
        currentExecuted = true;

        // If it is done --> call its onEnd() method
        if (current.done()) {
          currentDone = true;
          currentResult = current.onEnd();
        }

        // Check if this CompositeBehaviour is finished
        finished = checkTermination(currentDone, currentResult);
      } else {
        // The currently scheduled child is not runnable --> This
        // Composite behaviour must block too and notify upwards
        myEvent.init(false, NOTIFY_UP);
        super.handle(myEvent);
      }
    } else {
      // There are no children to execute
      finished = true;
    }
  }