Build a flexible tree with recursive data source