Fix gui tree view build visible tree

Retargeted version of #753