--!strict

local function FindPath<U>(parent: Instance, ...: string): U?
	local currentInstance: any = parent
	
	for _, pathSlice in { ... } do
		currentInstance = currentInstance:FindFirstChild(pathSlice)
		
		if not currentInstance then
			return nil
		end
	end
	
	return currentInstance
end

return FindPath
