optimize tree building for visible layer structure