Assign same material to all objects of the same diffuse color

Try this.

'''
By LoboTommy
Circa Blender 2.79

Go to object mode.
Select an object preferably of an unpicked diffuse material color.
Run the script (Hover over Text window and hit Alt P).
All materials of matching diffuse color are replaced by that of the selected object.

Fails on objects without materials if selected.
'''

import bpy

selMat = bpy.context.object.active_material
selCol = selMat.diffuse_color[:]

for obj in bpy.data.objects:
    if (obj.type == 'MESH' or obj.type == 'CURVE') and selCol == obj.data.materials[0].diffuse_color[:]:
        obj.data.materials[0] = selMat

By binning I meant to define ranges within the color gamut. Separate items according to some distinguishing criteria in other words. With the further info I ended up using an equality check rather than that approach.