Fixed a bug where clicking on main element of a tree causes NullReference