Replace collection with tree-structure