Checking if treemodel exists before changing the node selection.
Implemented duplicate method.