MULTIPLE Sensors in Nested Loop

Need a little help with Program Structure if anyone feels so kind.

I have a three switches ULS, UTS and LLS, which are U.pper L.imit S.witch, U.pper T.ag S.witch and L.ower L.imit S.witch respectively.

And a Stepper Motor connected to my Arduino Mega via a Gecko 203V which needs step and direction inputs.

Functionally all tests out fine. Motor turns CW and CCW as instructed at proper velocity. All three(3ea) switches toggle their respective bits no problem.

So here's the question.

I want to perform a digitialRead on ULS and UTS and perform the following:

Scenario 1: If UTS is LOW Output a HIGH on Pin 19 which effectively moves the motor CW until either UTS goes HIGH ULS goes HIGH

Scenario 2: If ULS goes HIGH ((and BTW if this happens their is no way for UTS to EVER go HIGH simultaneously)) output a LOW on Pin 19 Driving the motor CCW until LLS finally goes HIGH at which point the motor sits there until an operator resets the unit.

Here's my problem. If I try and perform Scenario 2 it competes with Scenario 1 trying to Force UTS HIGH.

basically, ignoring everything here, I need an example of a BASIC If THIS then do THIS, If This Other Thing, then do This Other Thing

Trying to stack of functional 'voids' just is the wrong way to do this....

...or is it?

Thanks All.

I would probably take the debounced values of the 3 switches and combine them into a 3-bit number, then use a switch() statement to select the appropriate actions. That can make for clearer logic than a bunch of nested ifs. Giving the bit combinations symbolic names can make the code more readable, too. E.g.:

switch_state = (uls_val << 2) | (uts_val < 1) | lls_val;
    switch (switch_state)
        {
        case AT_TOP: ...
        case NEAR_TOP: ...
        case IN_MIDRANGE: ...
        case AT_BOTTOM: ...
        }

Be sure to include error-handling cases to handle the "impossible" situations.