local w=require(script.Parent.rootTree)local function b(w,c)local H={}for w,B in w do local r=b(B,c:FindFirstChild(w)or error("\067\111\117\108\100 \110\111\116 \102\105\110\100 \099\104\105\108\100"..w))table.move(r,1,#r+1,#H+1,H)end if#H==0 then table.insert(H,c)end return H end local function c(w)local c={}for w,H in w do local B=b(H,game:GetService(w))table.move(B,1,#B+1,#c+1,c)end return c end return c(w)
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)
