BUG: Make sure the node is present before saving in a collection

While updating the scene, the tree view hierarchy was being saved. This causes
segfaults when updateScene is called after closing the scene or deleting nodes.
Check if the nodes are still present before saving them to collection.
Fixes issue 2557.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21880 3bd1e089-480b-0410-8dfb-8563597acbee
BUG: Save tree before the batch processing starts and restore after it ends

Saving the tree expansion state now happens before batch processing starts and
the consequent restoration happens after batch processing ends. This prevents
handling tree when the scene is in an inconsistent state during the batch
processing task.

BUG: Make sure scene tree save/restore happens during lazy update only

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21881 3bd1e089-480b-0410-8dfb-8563597acbee