How many IF/ELSE/ENDIF can be used in a script?
OP_IF
  OP_3 
OP_ELSE
  OP_IF
    lock1 OP_CLTV OP_DROP OP_2
  OP_ELSE
    lock2 OP_CLTV OP_DROP OP_1
  OP_ENDIF
OP_ENDIF
pub1 pub2 pub3 OP_3 OP_CHECKMULTISIG


some pseudocode:

var x = stack.pop ( );  // take the last item from stack and remove it
if ( x != 0 )
{
  stack.push ( 3 );  // push the number '3' to the stack
}
else
{
  var y = stack.pop ( ); // take next item
  if ( y != 0 )
  {
    stack.push ( locktime1 ); // push value
    stack.compare_top_value_with_timestamp_and_abort_if_not_valid ( );
    stack.pop ( ); // remove locktime1 if passed
    stack.push ( 2 );
  }
  else
  {
    stack.push ( locktime2 ); // push value
    stack.compare_top_value_with_timestamp_and_abort_if_not_valid ( );
    stack.pop ( ); // remove locktime2 if passed
    stack.push ( 1 );
  }
}
stack.push ( pub1 );
stack.push ( pub2 );
stack.push ( pub3 );
stack.push ( 3 );
stack.check_multi_sig ( );