There are a couple of things to keep in mind when creating groups (and subsequently gizmos), if you want to maintain full control over the way the input pipes behave and thus how the flow of data in the tool is handled:
When using more than one input in your group, make sure to set up the group's internals in such a way that the first Input node (and thus the group node's right most pipe) is connected to the main tree upstream, the one that should prevail if the group node is disabled.
Input name = pipe name.
To label the input pipes of a gizmo or group, simply change the respective Input node's name inside the group.
In this example I messed it up and used the first Input node inside my group to connect to the mask, and the second one to connect to the incoming image which is obviously my "main tree":
To correct this, I need to shuffle my internal Input nodes around and swap the inputs on my gizmo to make sure I keep things connected the right way (shift+x on the gizmo will do that in this case):
now fix the labels to make sense of it all again:
Now how do I know which input node is my "main" one without having to look at the pipe labels?!
Well, each Input node has a hidden knob called "number", which corresponds to the order in which their respective pipe is placed on the group node. To visualise this you can put in this little tcl snippet into the Input nodes' labels:
The input with number 0 is the one that will be piped through if the group is disabled.
Knowing about this hidden "number" knob now also enables you to use it in expressions to disable certain parts in your group to avoid error messages if a given pipe is not connected. Here I'm disabling an internal Copy node if the parent group's input 1 is not connected:
here is an example for a relative tcl expression that just checks if a node's second input ("input1") has an external connection through it's corresponding pipe:
![ exists parent.input[value input1.number] ]
You can assign new pipe numbers to Input nodes via python just like you would with any other knob, and you can also just copy/paste the group node into a text editor and change the Input nodes' number knobs there.
Just remember that each Input node must have a unique value in it's number knob or nuke will get confused.