better way to code recursive if statements
<p>I find myself in this position occasionally, and I'm sure there is a better way to do it than I am currently.</p>

<p>In this example, I'm trying to sort a group of times where I have conflicting items. I need to know what times are high-priority,can't be moved, vs low priority, can be moved. 
But I'm pretty sure this code is very inefficient. </p>

<pre><code>var holdLowPriorities = [];

for (conflict = 0; conflict &lt; sortedTimes.length - 1; conflict++) {
    var firstConflictTimeStart = sortedTimes[conflict][0];
    var firstConflictTimeEnd = sortedTimes[conflict][1];
    var secondConflictTimeStart = sortedTimes[conflict + 1][0];
    var secondConflictTimeEnd = sortedTimes[conflict + 1][1];

    if (firstConflictTimeStart &lt; secondConflictTimeEnd &amp;&amp; 
            firstConflictTimeEnd &gt; secondConflictTimeStart) {
        // are either of the conflicts a high priority
        var firstContactPriority = sortedTimes[conflict][2];
        var secondContactPriority = ortedTimes[conflict + 1][2]

        if (firstConflictPriority == 2) {
            //this is high priority, can't move
        }
        if (secondConflictPriority == 2) {
            // this is also a priority, but has to move
        }
        // are either of the conflicts a low priority?
        if (firstConflictPriority == 0) {
            // this is a low priority so I can adjust the time
        } else if (secondConflictPriority == 0) {
            // this is a low priority so I can adjust the time
        }
    }
}
</code></pre>

<p>Unfortunately, I don't even know what to call this type of a problem, and therefore don't know what to look for, though I'm sure the answer isn't overly complicated (I hope not anyway). </p>
