private Data getTopLevelComponentData(ProgramLocation location) {
		if (location == null) {
			return null;
		}

		Address address = location.getAddress();
		if (address == null) {
			return null;
		}

		Program program = provider.getProgram();
		Data topLevelData = program.getListing().getDataContaining(address);

		if (topLevelData == null || topLevelData.getNumComponents() <= 0) {
			return null; // no child data components
		}

		return topLevelData;
	}
Action for recursively collapsing an expandable data element in the listing.  This action
can be invoked on an expandable data element or any sub element and will close the
outer most data element and all child elements of that structure.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/actions/CollapseAllDataAction.java