How to Set visibility false of item?

In the screen shot attached I am trying to make all C1Them A visible false
and C1Them B visible true

How to achieve this.

I am hitting Edit scope error

selection.items.forEach(node => {
    console.log(node);
    node.visible = false; //this works
    node.children.forEach(function (childNode, i) {
        console.log(childNode.visible);
        childNode.visible = false; // this throws errir
    });
});

This is what i . see in console

Plugin Error: Plugin made a change outside the current edit context
at convertPluginErrorToString (plugins/PluginErrorUtil.js:1:198)
at internalFormatPluginError (plugins/PluginErrorUtil.js:1:1073)
at internalReportPluginError (plugins/PluginErrorUtil.js:1:1180)
at Object.reportPluginError (plugins/PluginErrorUtil.js:1:1612)
at r (plugins/ScenegraphGuard.js:1:550)
at Object.checkChange (plugins/ScenegraphGuard.js:1:1067)
at Object.EventEmitter._emitEvent (third_party/events.js:1:1178)
at Object.EventEmitter.emit (third_party/events.js:1:1668)
at SymbolGroup.Group.notifyChanged (lib/scenegraph/GroupExtension.js:1:1030)
at SymbolInstance.<anonymous> (plugins/ScenegraphWrappers.js:1:8365)
at SymbolInstance.<anonymous> (plugins/ScenegraphWrappers.js:1:2622)
at /Users/ashwin/Library/Application Support/Adobe/Adobe XD/develop/Switch-Them/main.js:19:31
at plugins/WrapperList.js:1:378
at LinkedList.forEach (lib/LinkedList.js:1:1534)
at ReadOnlyList.forEach (lib/ReadOnlyList.js:1:282)
at WrapperList.forEach (plugins/WrapperList.js:1:354)
at selection.items.forEach.node (/Users/ashwin/Library/Application Support/Adobe/Adobe XD/develop/Switch-Them/main.js:17:23)
at Array.forEach (<anonymous>)
at switchTheme0 (/Users/ashwin/Library/Application Support/Adobe/Adobe XD/develop/Switch-Them/main.js:14:21)
at Object.execScenegraphEdit (plugins/ScenegraphGuard.js:1:4685)
at BaseCommand._invokePluginCommand [as _commandFn] (plugins/PluginLoader.js:1:5471)
at BaseCommand.execute (lib/BaseCommand.js:1:929)
at Object.T [as executePluginCommand] (././js/0.js:73:54360)
at b._uiEntry.panelId._uiEntry.commandId.n.onclick.e (././js/0.js:95:47055)

Hi @bisketashwin, Adobe XD has a limited edit scope based on user’s selection. (see edit context limitation). This prevents plugins from editing special objects like boolean groups, repeat grids, and others if they are nested more than 1 level further under the selected object.

In order to make this work, you would need to direct users to click into the object they want to run your plugin on.