local function H(G,n,Q)if G==n then return true end local O=type(G)local Y=type(n)if O~=Y then return false end if O~="\116\097\098\108\101"then return false end if not Q then local H=getmetatable(G)if H and H.__eq then return G==n end end local u={}for G,O in pairs(G)do local Y=n[G]if Y==nil or not H(O,Y,Q)then return false end u[G]=true end for H,G in pairs(n)do if not u[H]then return false end end return true end return H
--[[
	Takes two tables A and B, returns if they are deeply equal. ignoreMetatables specifies if metatables should be ignored
	in the deep compare
	Assumes tables do not have self-references
]]

local function deepEqual(A, B, ignoreMetatables)
	if A == B then
		return true
	end
	local AType = type(A)
	local BType = type(B)
	if AType ~= BType then
		return false
	end
	if AType ~= "table" then
		return false
	end

	if not ignoreMetatables then
		local mt1 = getmetatable(A)
		if mt1 and mt1.__eq then
			--compare using built in method
			return A == B
		end
	end

	local keySet = {}

	for key1, value1 in pairs(A) do
		local value2 = B[key1]
		if value2 == nil or not deepEqual(value1, value2, ignoreMetatables) then
			return false
		end
		keySet[key1] = true
	end

	for key2, _ in pairs(B) do
		if not keySet[key2] then
			return false
		end
	end
	return true
end

return deepEqual
