Logic and control flow are two very complex subjects, on the whole, but they both trace back to simple decisions, in many cases binary, either..or, and in others what I like to call multi-way, or *n-ary* such as above where there are multiple conditions to test against.

I'll grant the logic can sometimes be frustrating, and can offer a bit of condolence in the form of a little stick of wood and graphite called a pencil. We can trace our entire program in diagram form with a pencil and paper. Work it out on paper, and translate to code algorithm. When debugging, do the reverse... Translate the code algo back to a pencil diagram. The flaws will jump off the paper, in many instances.

You will be amazed with how fast you begin to visualize program flow and logic. How we might illustrate our logic is up to us, but we do have a standard to fall back on, if we wish... The flow chart. It's symbols are adopted and documented and everywhere to be found.

After a time we can develop our own intuitive form of illustration. I use a shoelace forming a circle with one intersection of the string to represent a function. The bottom of the the hoop is the callee, and the intersection is the caller. For scope I use a tree diagram. A lot of my pencil work is just dots and lines.

Today, it is truly just in my head, but it took using a pencil for many years to get here. Get out the pencil and paper and devise a way to utilize to the fullest in helping you to write and test all manner of algorithm. It's like training wheels for programmers, and more, a teaching tool that never gets old or discarded. We never throw away our pencil.