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.
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