// push...
if (currentStep instanceof Action) {
return (Action) this.stack.pop();
} // case: next step is a plan
else if (currentStep instanceof Plan) {
Plan newPlan = (Plan) currentStep;
if (newPlan.size() > 0) {
this.stack.push(newPlan.removeFirst());
} else {
this.stack.pop();
}
return this.execute(percept);
} // case: next step is an if-then