rewrite build_categories_tree for dagnabit