public static Symbol createPreferredLabelOrFunctionSymbol(Program program, Address address,
			Namespace namespace, String name, SourceType source) throws InvalidInputException {

		try {
			if (!address.isMemoryAddress()) {
				throw new IllegalArgumentException("expected memory address");
			}
			if (namespace == null) {
				namespace = program.getGlobalNamespace();
			}

			SymbolTable symbolTable = program.getSymbolTable();

			// check for symbol already existing at address
			Symbol symbol = symbolTable.getSymbol(name, address, namespace);
			if (symbol != null) {
				return symbol;
			}

			if (namespace.isGlobal()) {
				// do not add global symbol if same name already exists at address
				for (Symbol s : program.getSymbolTable().getSymbolsAsIterator(address)) {
					if (name.equals(s.getName())) {
						return null;
					}
				}
			}
			else {
				// change namespace on global symbol with same name
				symbol = symbolTable.getGlobalSymbol(name, address);
				if (symbol != null) {
					symbol.setNamespace(namespace);
					return symbol;
				}
			}

			// create new symbol if needed
			return symbolTable.createLabel(address, name, namespace, source);
		}
		catch (DuplicateNameException | CircularDependencyException e) {
			throw new AssertException(e);
		}
	}
Create label symbol giving preference to non-global symbols.  An existing function symbol
may be returned.  If attempting to create a global symbol and the name already exists 
at the address no symbol will be created and null will be returned.  
If attempting to create a non-global symbol, which does not exist,
and a global symbol does exist with same name its namespace will be changed. 
@param program program within which the symbol should be created
@param address memory address where symbol should be created
@param namespace symbol namespace or null for global
@param name symbol name
@param source symbol source type
@return new or existing label or function symbol or null if creating a global symbol
whose name already exists at address
@throws InvalidInputException if invalid symbol name provided
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/symbol/SymbolUtilities.java