Why does Hierholzer's algorithm work?
When you get stuck at vertex , you've used all edges incident to . Since degrees are even (or is an endpoint), you must be at the end of a valid path segment.
The stack stores your current position. By popping when stuck and pushing to the result, you build the path from end to start.
Invariant: At any point, unused edges still form a valid Eulerian subgraph. You can always find a path through them.
The reversed path at the end gives you the correct order from start to finish.