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