Umm you really dont want to do this in script. Its not very handy to do this, theres lot more to consider.
For example let us suppose you adjust gamma globally on all your nodes. Do you really think finding all the things that are colors helps?
I mean many nodes such as multiply divide are 3 float multi attribs but they are not colors. However they MAY represent a color in the final product nevertheless by implication. Worse even non multi attributes might represent a color down the stream. So how do you decide at what point to put in the manipulation? Well you could just nodalize the connection and just manipulate true sources. But then youd have to decide what a true source is and make sure NOT to affect parents in its graph.
Now even worse then that you cant possibly know if the source of this is a target of a totally legitimate sure to be colors you want to change, in which case you DONT want the gamma node input, but then again you might because the inner calculation in between might need to be gamma independent which means you need 2 gamma nodes.
Second problem, everything being equal in maya makes it hard for yu to decide if a color attribute is actually being used a s a color, or just a float source for a transform for example. Worse it could be used as BOTH at the same time.
So making this idiot proof is a bit hard. But yes you can ask maya if something was created as float3 variable:
getAttr -type "lambert1.color";
// Result: float3 //
EVEN WORSE: all vertex locations are of type float3 and they are 2 times in the scene
But the API does know if they were implicitly created as colors or not, but again this info isn't as revealing as you might think.