public static Library getContainingLibrary(Symbol symbol) {
		if (symbol == null) {
			return null;
		}
		if (symbol.getSymbolType() == SymbolType.LIBRARY) {
			return (Library) symbol.getObject();
		}
		if (symbol.getSymbolType() == SymbolType.NAMESPACE ||
			symbol.getSymbolType() == SymbolType.CLASS) {
			while (symbol != null && symbol.isExternal()) {
				Namespace n = (Namespace) symbol.getObject();
				if (n instanceof Library lib) {
					return lib;
				}
				symbol = n.getParentNamespace().getSymbol();
			}
		}
		return null;
	}
Get the Library which contains the specified external symbol.
@param symbol external symbol
@return null if symbol is null or not external
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Library.java