Generate groups as tree objects