Improve tree selection handling