Use a tree instead of flat array to avoid angular error 'infdig'