Select objects by shader

Hello!
Is there a working script to select object by shader in Clarisse some where? I found this script a while ago I don't know where I found it but it stops only with one object selected. Anybody that knows a better script or how to fix the script to select all objects? Thank you in advance.
Is there a working script to select object by shader in Clarisse some where? I found this script a while ago I don't know where I found it but it stops only with one object selected. Anybody that knows a better script or how to fix the script to select all objects? Thank you in advance.
python code
import ix
# from clarisse_helper import *
import pprint
def list_all_objects():
"""
List all objects in the scene.
"""
all_objects = ix.api.OfObjectArray()
all_classes = ix.application.get_factory().get_classes().get_classes()
object_list = []
for c in all_classes:
c_name = c.get_name()
ix.application.get_factory().get_all_objects(c_name, all_objects)
for o in all_objects:
object_list.append(o.get_full_name())
return list(set(object_list))
def get_shader_relations(object_list):
"""
Returns a dictionary with all the shader relations for the given objects.
"""
shader_relations = {}
for obj in object_list:
obj = ix.get_item(obj)
try:
shader = obj.attrs.materials[0]
shader_name = str(shader.get_name())
if not shader_name in shader_relations.keys():
shader_relations[shader_name] = [obj]
else:
shader_relations[shader_name].append(obj)
except:
pass
return shader_relations
print("--------------------------------------------------------------------------------------------------------")
# Get shader relations for entire scene
shader_relations = get_shader_relations(list_all_objects())
print("All shader relations:")
pprint.pprint(shader_relations)
# print(ix.selection[0].attrs.materials)
try:
selection = ix.selection.get_objects()[0]
except:
raise RuntimeError("You didn't select anything it seems.")
# ix.selection.select()
selection = str(selection).rpartition("/")[-1]
related_objects = shader_relations[selection][0].get_full_name()
print("Related_objects: {0} - {1}".format(type(related_objects), related_objects))# TODO only the selection and sorting remains...
ix.selection.select(ix.get_item(related_objects))
# print(selection)
# print(shader_relations[selection])