function BrioUtils.flatten(u)local k={}local F={}for u,c in pairs(u)do if Brio.isBrio(c)then if c:IsDead()then return Brio.DEAD else table.insert(F,c)k[u]=c:GetValue()end else k[u]=c end end return BrioUtils.first(F,k)end

function BrioUtils.flatten(brioTable)
	local newValue = {}
	local brios = {}

	for key, brio in pairs(brioTable) do
		if Brio.isBrio(brio) then
			if brio:IsDead() then
				return Brio.DEAD
			else
				table.insert(brios, brio)
				newValue[key] = brio:GetValue()
			end
		else
			newValue[key] = brio
		end
	end

	return BrioUtils.first(brios, newValue)
end
