protected Varnode getMemoryValue(List<HashMap<Address, Varnode>> valStore, int backupDepth, Varnode varnode,
			boolean signed) {
		// traverse pushed memory value states until find value
		// if don't find, return null

		// build up an array entry for each byte, if any missing, return
		int size = varnode.getSize();
		Varnode split[] = new Varnode[size];
		Address addr = varnode.getAddress();

		for (int i = 0; i < size; i++) {
			// go to thru stack til hit for each i
			// accumulate each byte, if get to end, fail
			HashMap<Address, Varnode> stateLayer = null;
			int layer = valStore.size() - 1 - backupDepth;
			while (layer >= 0) {
				stateLayer = valStore.get(layer);
				if (stateLayer == null) {
					break;
				}

				Varnode value = stateLayer.get(addr.addWrapSpace(i));
				if (value != null) {
					split[i] = value;
					break;
				}
				stateLayer = null;
				layer--;
			}

			if (stateLayer == null) {
				return null;
			}
		}

		// no have an array, re-assemble
		// if const, then each must be a const byte
		// if symbolic, each must be same symbolic value of correct size
		long value = 0;
		Varnode type = split[0];
		int typesize = type.getSize();
		boolean isconst = type.isConstant();
		if (!isconst && (typesize != 0 && typesize != size)) {
			return null;
		}
		for (int i = 0; i < split.length; i++) {
			Varnode vb = split[i];
			if (vb.getSpace() != type.getSpace()) {
				return null;
			}
			if (isconst) {
				// assemble constant
				value |= (vb.getOffset() << (isBE ? (size - i - 1) : i) * 8);
			}
			else if (type != vb) {
				return null;
			}
		}

		if (isconst) {
			if (size != 0) {
				value = (!signed ? value : ((value << (8 - size) * 8)) >> ((8 - size) * 8));
			}
			return createConstantVarnode(value, size);
		}

		if (signed && typesize != 0 && typesize < 8) {
			value = type.getOffset();
			value = ((value << (8 - size) * 8)) >> ((8 - size) * 8);
			return createVarnode(value, type.getSpace(), type.getSize());
		}
		return type;
	}
Search the value state stack for the first occurrence of the set value

@param varnode varnode to search for a value
@param signed true if retrieving a signed value
@return first value found on stack, null otherwise
Ghidra/Features/Base/src/main/java/ghidra/program/util/VarnodeContext.java