better logic to switch the tree node icon.