local e=require(script.Parent.rootTree)local function Q(e,U)local P={}for e,m in e do local g=Q(m,U:FindFirstChild(e)or error("\067\111\117\108\100 \110\111\116 \102\105\110\100 \099\104\105\108\100"..e))table.move(g,1,#g+1,#P+1,P)end if#P==0 then table.insert(P,U)end return P end local function U(e)local U={}for e,P in e do local m=Q(P,game:GetService(e))table.move(m,1,#m+1,#U+1,U)end return U end return U(e)
local rootTree = require(script.Parent.rootTree)

local function getRoots(node, parent)
	local roots = {}

	for key, subNode in node do
		local subRoots =
			getRoots(subNode, parent:FindFirstChild(key) or error("Could not find child" .. key))
		table.move(subRoots, 1, #subRoots + 1, #roots + 1, roots)
	end

	if #roots == 0 then
		table.insert(roots, parent)
	end

	return roots
end

local function getAllRoots(node)
	local roots = {}

	for key, subNode in node do
		local subRoots = getRoots(subNode, game:GetService(key))
		table.move(subRoots, 1, #subRoots + 1, #roots + 1, roots)
	end

	return roots
end

return getAllRoots(rootTree)
