Finding the top / starting point of the node tree using Blender's Python API I am working on an exporter, for Babylon.JS, for a version of Blender which does not have the internal render (developing in 2.79 though).  For previous versions of the exporter, if a material with nodes was encountered, baking was just done right in the exporter.

Babylon.JS supports Physically Based Rendering (PBR), and materials similar for the internal render, so I want to try to map things when possible.

Leads me to, how do I know where to start walking the tree.  I could just run through the nodes checking for an output material like:

for shader in material.node_tree.nodes:
    shaderName = shader.bl_idname
    if shaderName == 'ShaderNodeOutputMaterial':
        # got it


Think there must be a better way.  Though it might be stupid, you can add more than one of that type, yet the UI knows which is the one hooked up.

Another way might look for a node which has no outputs, but I can see the same issue.
Yes, once I found the term active_output, I pointed straight to here

This question can probably be deleted.