How to add shader nodes and corresponding links to transparent materials assigned to

In my setting, I have lots of objects consisting of many different meshes. Some of these meshes come with transparent materials applied to them. Based on this answer, I can identify the meshes with transparent materials in my objects as follow (thanks to gandalf3♦) using the following Python script:

for obj in
    if obj.type == 'MESH':
        for slot in obj.material_slots:
            if slot.material:
                mat = slot.material
                for node in mat.node_tree.nodes:
                    if node.label == "Mix Color/Alpha":
                        if node.inputs[1].default_value[0] < 1:
                            print("Material '%s' on object '%s' seems transparent" % (,

Also, based on this answer I can manually add shader nodes to get depth maps or surface Normals while ignoring those materials (again, thanks to gandalf3♦) as shown below:

I need to do this process for thousands of objects. I am pretty new to the concepts of nodes in Blender and do not know how to use the provided code snippet to modify the nodes. So I wonder, for each mesh which has been assigned a transparent material, how can I add the math (less than) and mix shader nodes and add/remove the corresponding links using Python?
You can download this .obj file and load it in Blender to be able and make sure your code works. Just make sure you have selected Cycles before importing the obj file into Blender so that Blender creates the materials’ nodes lists automatically.

NOTE: I’m not sure how this helps but some of the meshes share the same materials. For instance, in the car example, the headlamps and the glasses (windshield, side windows) share the same material.

NOTE: Do not worry if you cannot get the same Normal maps as shown here. The surface Normals of the object I provide here are incorrect. If you want to get the same surface Normals you need to do the following: after you do the operations to add shader nodes, you may join all the meshes. Then go edit mode and recalculate outside surface Normals of the downloaded object. Then turn off Auto Smooth.

You already know how to loop through the objects in the file and their material slots and materials and nodes in their node trees. Have a look at these they are useful also autocomplete(ctrl+space) function in the Python console is priceless: