Building hierarchical structures for 3D scenes with repeated elements