Some years ago, I asked a question of dandelO (Martin) on how to create a node that contains a chain of nodes in order to clean of the main chain of nodes. And, he replied with this explanation ...thanks again Martin:
Hiya, Bob.
Normally what I do is build out all my nodes in the main network view that will make up whatever shader I'm making, when I have all the nodes finished and the shader is working properly I'll take a basic surface layer node(uncheck any colour settings so it is basically doing nothing other than just sitting in the general area waiting to be used).
All the nodes that make up any particular effect I'd plug the last one in the chain into the 'child layer' input of the surface layer, there you can use the surface layer constraints and such to control all those child nodes in the set.
To go the little step further that you're asking about and have the clutter-nodes inside, just draw a marquee selection(or shift+click) for all the nodes you want to lift. Once they are highlighted you can press ctrl+x(cmd+x on Mac, I think) to 'cut' the nodes from the view. This copies all the nodes to your clipboard. Next, right-click the empty surface layer that will be the parent node and select 'internal network'. It'll take you inside that node. Hit 'ctrl+v' to paste all the nodes you just 'cut' a second ago, now they are all inside the parent surface layer... But, they aren't yet connected yet, are they?
So, click 'up one level' to focus the surface layer you've just been inside and then right-click whichever top input node of that layer you want to assign a shader to. In this case it's the 'child layer' input. The options 'assign shader' and 'create new shader' should pop up when you right-click, select 'assign' and then just navigate to the node through that menu list to assign whichever was your last node in the internal network chain you've just pasted. It will be easy to find the node you want to assign to as it will be listed in a hierarchical menu form.
All the input nodes on top of a surface layer can be used this way so you can pop all your colour nodes inside a layer and use the 'colour function'(or any other) input to select and assign any node to any input, even if they are inside other completely different node networks, or wherever else you like.
You'll notice once you've done that the top input will disappear and will now be inside the network of the shader with your selection already connected.
You can bring inputs back to the outside by selecting a different input node from the node settings panel(the main double-click node settings window). Just select a shader that isn't inside another node to do that.
You can't bring a 'child layer' input back to the front though without using a text editor, as there is no pop-out menu in a surface layer settings panel to select what to use as a child layer.
As usual, I've typed a dictionary when a few lines would have done!
Give's a shout if you get stuck, man, I normally over-complicate things by drivelling on for ages, but I'm always around and here to help.
Martin.
Hope you all find this useful.
Bob