Having trouble implementing a function in the node editor where the source uses if/else logic I am creating a color saturation node group in blender as an exercise. This is the code I'm trying to implement:
RGBtoHSV= function(color) {
    var r,g,b,h,s,v;
    r= color[0];
    g= color[1];
    b= color[2];
    min = Math.min( r, g, b );
    max = Math.max( r, g, b );


    v = max;
    delta = max - min;
    if( max != 0 )
        s = delta / max;        // s
    else {
        // r = g = b = 0        // s = 0, v is undefined
        s = 0;
        h = -1;
        return [h, s, undefined];
    }
    if( r === max )
        h = ( g - b ) / delta;      // between yellow &amp; magenta
    else if( g === max )
        h = 2 + ( b - r ) / delta;  // between cyan &amp; yellow
    else
        h = 4 + ( r - g ) / delta;  // between magenta &amp; cyan
    h *= 60;                // degrees
    if( h &lt; 0 )
        h += 360;
    if ( isNaN(h) )
        h = 0;
    return [h,s,v];
};

This is the part that I am struggling to implement:
    if( r === max )
    h = ( g - b ) / delta;      // between yellow &amp; magenta
else if( g === max )
    h = 2 + ( b - r ) / delta;  // between cyan &amp; yellow
else
    h = 4 + ( r - g ) / delta;  // between magenta &amp; cyan

I am trying to figure out how to chain math comparison nodes in the right way but I am just stuck.
Here is the node group so-far (Updated):

At the very end is where I am stuck. I'm not sure how to set up a three-way if/else node structure.
If r === max, else if g === max, else catch-all.
Any help would be hugely, hugely, appreciated!
Rewrite the code as
h1 =     (g - b) / delta;  // between yellow &amp; magenta
h2 = 2 + (b - r) / delta;  // between cyan &amp; yellow
h3 = 4 + (r - g) / delta;  // between magenta &amp; cyan

h  = (r==max) * h1
h += (1 - (r==max)) * (g==max) * h2
h += (1 - (r==max)) * (1 - (g==max)) * h3

where (X==Y) means 1 if X and Y are equal, 0 if they're different (ie. what the &quot;Compare&quot; operation on a Math node does).
This is just a bunch of arithmetic operations, so it's straightforward, albeit laborious, to translate into nodes.
edit
Here's how I did it with nodes. This does
tmp = (g==max) ? h2 : h3;
h   = (r==max) ? h1 : tmp;


The If Then Else node can be done with a lerp