Simplify tree click handling and deselect tree selection when last tab
is closed.