protected function getPreviousStepIndex($popStack)
{
$history = $this->getHistory();
if ($history->getCount() >= 0) {
$activeStepIndex = $this->getActiveStepIndex();
$previousStepIndex = -1;
if ($popStack) {
$previousStepIndex = $history->pop();
if ($activeStepIndex === $previousStepIndex && $history->getCount() > 0) {
$previousStepIndex = $history->pop();
}
} else {
$previousStepIndex = $history->peek();
if ($activeStepIndex === $previousStepIndex && $history->getCount() > 1) {
$saveIndex = $history->pop();
$previousStepIndex = $history->peek();
$history->push($saveIndex);
}
}
return $activeStepIndex === $previousStepIndex ? -1 : $previousStepIndex;
} else {
return -1;
}
}