Yes, but the code needs to be structured differently. Correct stack-based recursive algorithm modeling should keep the node on the stack until the node and its children are fully traversed. The stack should contain instances of a class that contains information about how many children were passed, for example:
public class StackElement<T> {
public Tree<T> node;
public int numTraversedChildren;
}
( ). , node , StackElement, node numTraversedChildren 0. ( ) , . numTraversedChildren == 2, , node . ( , ), node, . node , numTraversedChildren ( numTraversedChildren 0), ( numTraversedChildren 1).
, while push/pop : push - , pop - , . .