private static List<Namespace> doGetNamespaces(List<String> namespaceNames,
			Namespace root, Program program, boolean searchWithinAllLibraries) {

		if (root == null) {
			root = program.getGlobalNamespace();
		}

		List<Namespace> parents = Arrays.asList(root);

		if (searchWithinAllLibraries && root.isGlobal() && !namespaceNames.isEmpty()) {
			ExternalManager extMgr = program.getExternalManager();
			String ns = namespaceNames.get(0); // only consider if first namespace is not Library
			if (extMgr.getExternalLibrary(ns) == null) {
				parents = new ArrayList<>();
				parents.add(root);
				for (String libraryName : extMgr.getExternalLibraryNames()) {
					parents.add(extMgr.getExternalLibrary(libraryName));
				}
			}
		}

		for (String name : namespaceNames) {
			List<Namespace> matches = getMatchingNamespaces(name, parents, program);
			parents = matches;
		}
		return parents;
	}
Returns a list of namespaces that match the given path.  The path can be
relative to the given root namespace or absolute if the path begins with
the global namespace name.

<P>Note: this path must only contain Namespace names and no other symbol types.

@param program the program to search
@param parent the namespace to use as the root for relative paths. If null, the
		  global namespace will be used
@param pathString the path to the desired namespace
@return a list of namespaces that match the given path.  An empty list is returned 
        if none found.
@throws IllegalArgumentException if specified parent Namespace is not valid for 
        specified program.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/NamespaceUtils.java