python code for existing node chain blender
I have written a tool for that, but it has only features I needed for my nodetrees. The code is ugly, but might give some pointers for you in case you'd want to write something like that yourself. Maybe there are other - more complete - tools like that I'm not aware of.