Build a market group tree