goToStepWithTarget = function goToStepWithTarget(direction, cb) {
      var target, step, goToStepFn;

      if (currStepNum + direction >= 0 && currStepNum + direction < currTour.steps.length) {

        currStepNum += direction;
        step = getCurrStep();

        goToStepFn = function goToStepFn() {
          target = utils.getStepTarget(step);

          if (target) {
            //this step was previously skipped, but now its target exists,
            //remove this step from skipped steps set
            if (skippedSteps[currStepNum]) {
              delete skippedSteps[currStepNum];
            }
            // We're done! Return the step number via the callback.
            cb(currStepNum);
          } else {
            //mark this step as skipped, since its target wasn't found
            skippedSteps[currStepNum] = true;
            // Haven't found a valid target yet. Recursively call
            // goToStepWithTarget.
            utils.invokeEventCallbacks('error');
            goToStepWithTarget(direction, cb);
          }
        };

        if (step.delay) {
          setTimeout(goToStepFn, step.delay);
        } else {
          goToStepFn();
        }
      } else {
        cb(-1); // signal that we didn't find any step with a valid target
      }
    }
goToStepWithTarget

Helper function to increment the step number until a step is found where
the step target exists or until we reach the end/beginning of the tour.

@private
@param {Number} direction Either 1 for incrementing or -1 for decrementing
@param {Function} cb The callback function to be invoked when the step has been found