@Override
	public void actionPerformed(ActionContext context) {
		// This actions does double duty.  When invoked from the icon, it closes all nodes.
		// When invoked from the popup, it only closes selected nodes.

		if (!(context instanceof DataTypesActionContext)) {
			collapseAll(plugin.getProvider().getGTree()); // on the toolbar or filter field--collapse all
		}

		DataTypesActionContext dataTypeContext = (DataTypesActionContext) context;
		if (dataTypeContext.isToolbarAction()) {
			collapseAll(plugin.getProvider().getGTree()); // on the toolbar or filter field--collapse all
		}
		else {
			DataTypeArchiveGTree gtree = (DataTypeArchiveGTree) context.getContextObject();
			TreePath[] selectionPaths = gtree.getSelectionPaths();
			if (selectionPaths == null || selectionPaths.length != 1) {
				// no paths selected; close all paths
				collapseAll(plugin.getProvider().getGTree());
			}

			if (selectionPaths != null) {
				for (TreePath path : selectionPaths) {
					GTreeNode node = (GTreeNode) path.getLastPathComponent();
					if (node instanceof ArchiveRootNode) { // if the root is selected collapseAll
						collapseAll(gtree);
						return;
					}
					gtree.collapseAll(node);
				}
			}
		}
	}
Only shows up if all selected nodes are collapsable.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/CollapseAllArchivesAction.java