private Namespace getOrCreateNamespaces(Program program, SymbolPath symbolPath,
			Namespace rootNamespace) {
		SymbolPath parentPath = symbolPath.getParent();
		if (parentPath == null) {
			return rootNamespace;
		}

		//
		// Prefer a non-function namespace.  This allows us to put a function inside of a namespace
		// sharing the same name.
		//
		SymbolPath fullPath = new SymbolPath(rootNamespace.getSymbol()).append(parentPath);
		Namespace nonFunctionNs = NamespaceUtils.getNonFunctionNamespace(program, fullPath);
		if (nonFunctionNs != null) {
			return nonFunctionNs;
		}

		//
		// At this point we can either reuse an existing function namespace or we have to create
		// a new non-function namespaces, depending upon the names being used.  Only use an
		// existing function as a namespace if none of namespace path entries match the function
		// name.
		//
		String name = symbolPath.getName();
		if (!parentPath.containsPathEntry(name)) {
			Namespace functionNamespace =
				NamespaceUtils.getFunctionNamespaceContaining(program, parentPath, addr);
			if (functionNamespace != null) {
				return functionNamespace;
			}
		}

		CreateNamespacesCmd cmd =
			new CreateNamespacesCmd(parentPath.getPath(), rootNamespace, SourceType.USER_DEFINED);
		if (cmd.applyTo(program)) {
			return cmd.getNamespace();
		}

		errorMessage = cmd.getStatusMsg();
		return null;
	}
Constructs a new command for renaming a label within currentNamespace and changing the
namespace to newNamespace.

@param addr Address of label to be renamed
@param oldName the current name of the label to be renamed
@param newName the new name for the label. (null for default)
@param currentNamespace the symbol's current parent name space; null for global namespace
@param newNamespace the desired namespace; null for global namespace
@param source the source of this symbol
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/label/RenameLabelCmd.java