make CellSelection work with tree mode

Another patch for issue #761
Inspired of 87fe012e3e8b808b38fba194819819588e76ca09