local function r(r)local H=NodeLookup[r]if not H then return end local o=nodeIsVisible(H)Selection:Remove(r,true)local S=H.Parent remove(S,H.Index)NodeLookup[r]=nil connLookup[r]:disconnect()connLookup[r]=nil if o then updateList()elseif nodeIsVisible(S)then updateScroll()end end
-- Removes an object's tree node. Called when the object stops existing in the
-- game tree.
local function removeObject(object)
	local objectNode = NodeLookup[object]
	if not objectNode then
		return
	end

	local visible = nodeIsVisible(objectNode)

	Selection:Remove(object, true)

	local parent = objectNode.Parent
	remove(parent, objectNode.Index)
	NodeLookup[object] = nil
	connLookup[object]:disconnect()
	connLookup[object] = nil

	if visible then
		updateList()
	elseif nodeIsVisible(parent) then
		updateScroll()
	end
end
