PyQGIS 2 has a function to expand/collapse a layers with a subset of styles in the Layers panel as follows:
self.iface.legendInterface().setLayerExpanded(self.segments_layer, False)
I know that in PyQGIS 3 self.iface.legendInterface()
has been replaced by gsProject.instance().layerTreeRoot()
but making that switch in this case produces an error:
AttributeError: 'QgsLayerTree' object has no attribute 'setLayerExpanded'
What is the appropriate replacement for setLayerExpanded
in PyQGIS 3?