from krita import * active = Krita.instance().activeDocument() queue = [active.rootNode()] while len(queue) > 0: node = queue.pop() if node: if node.name() == "Pencils": node.setVisible(False) for child in node.childNodes(): queue.append(child) active.refreshProjection()