Ended up pulling out an iPad, and using Procreate to draw a bunch of overlapping boxes, and determined that strict stacks weren't going to work here and I was going to have to look for the actual value in the stack and remove it. But that most of the time it would be the top element, so this would be fine.
I don't mostly visualize when coding, and when I need to, most of my capacity is already taken up by something complex. So I have a growing collection of these sort of squiggly impressionistic diagrams, which I sketch out so I can fix the visual component of what I'm working on, to free up some capacity for the real work, which is just, thinking.
Pen and paper are not nearly so good for this as Procreate, I've found, because I can undo marks, and rather frequently do so, in a way which is much more fluid than erasing pencil marks. I can even try several approaches, by making new layers, and cacheing them by setting them invisible, trying again, juxtaposing, and so on.
I agree with the sibling comment that the intellectual work of programming is primarily verbal in character, although it can certainly draw on spacial reasoning at times. This, along with arguments from density, leaves me broadly pessimistic that "visual coding" will ever prove itself as a useful tool, and very skeptical indeed that it could ever be a durable replacement for syntax-based programming.
It also calls for a fair amount of arithmetic, for which I keep a Julia REPL open at all times, and a smaller but significant amount of higher maths, for which said REPL is also a treasured resource. But surprise surprise, it's mostly logic, and while the validity of logic is amenable to mathematics, its soundness cannot be resolved that way, but only through reasoning in an irreducibly verbal fashion. Or experiment, which is of value in programming, but the logic of programs is not nearly so empirical as that of real life.