[jQuery] Adding an if(condition) traversal mechanism...

[jQuery] Adding an if(condition) traversal mechanism...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Arial">I've been playing with this...
$.fn.if = function(flag) {
    return (flag) ? this.pushStack( this ) : this.pushStack( [] );
};
You can then do stuff like:
var addEdges = function(selector,opts) {
   $('.selector)
      .addClass('selected')
      .if(opts.page>1)
          .addClass('more-left')
      .end()
      .if(opts.page<opts.num_pages)
          .addClass('more-right')
      .end();
</font><font face="Arial">}
It's overkill, but having if statements in a jQuery chain makes for
pleasant reading IMHO.
My brain started to hurt when I tried adding ".else()" and also when I
started thinking of "if ... else ... end" or things like "if ... else
if ... end" and nesting, etc.
Anyone got any ideas on how to extend my basic ".if()" ?
Guy
</font>
</body>
</html>