// write the return statement
poppedElement.writeReturnStatement(writer);
} else {
// check if the pop results to moving up one level, if so set a new current parent
// if the next item on the stack as a different index then we are moving up, so set the parent to the next level
if (poppedElement.depthIndex() != stack.peek().depthIndex()) {
currentParent = stack.peek();
}
currentParent.add(poppedElement, writer);
}