Scanning every material's diffuse channel and adding a specific output node to it

Hi all,
I am wondering how to go about with scripting an output node across all materials in a scene (whether they have or not a map) and adding an output node in SME with a specific graph configuration.

This will be one of my 1st incursions on scripting, and I need to know where to start to get something like this done. Any help leading me there would be awesome! :)

AttachmentSize
capture.png18.61 KB