if (t.equals(task)) {
log.debug("Ending task {}.{}", t.getGroup(), t.getName());
break;
} else {
log.debug("Ending task {}.{} because it's a sub-task", t.getGroup(), t.getName());
t.endTask();
}
}
if (!stack.isEmpty()) {
stack.peek().subTaskEnded();
}