local function k(k,A)local S=NodeLookup[k]if not S then return end local X=NodeLookup[A]if not X then return end local c=nodeIsVisible(S)remove(S.Parent,S.Index)S.Parent=X S.Depth=depth(k)local function D(k,A)for S=1,#k,1 do k[S].Depth=A D(k[S],A+1)end end D(S,S.Depth+1)insert(X,#X+1,S)if c or nodeIsVisible(S)then updateList()elseif nodeIsVisible(S.Parent)then updateScroll()end end

local function moveObject(object,parent)
	local objectNode = NodeLookup[object]
	if not objectNode then
		return
	end

	local parentNode = NodeLookup[parent]
	if not parentNode then
		return
	end

	local visible = nodeIsVisible(objectNode)

	remove(objectNode.Parent,objectNode.Index)
	objectNode.Parent = parentNode

	objectNode.Depth = depth(object)
	local function r(node,d)
		for i = 1,#node do
			node[i].Depth = d
			r(node[i],d+1)
		end
	end
	r(objectNode,objectNode.Depth+1)

	insert(parentNode,#parentNode+1,objectNode)

	if visible or nodeIsVisible(objectNode) then
		updateList()
	elseif nodeIsVisible(objectNode.Parent) then
		updateScroll()
	end
end
