The title may not exactly sound. The essence is this. there is a certain List (Map), the structure of which is approximately the same
id=0; title="нулевой уровень"; parent=null id=1; title="уровень 0.1"; parent=0 id=11; title="нулевой уровень 1"; parent=null id=111; title="уровень 1.0"; parent=11 id=1111; title="нулевой уровень"; parent=111 roughly speaking, this is a product catalog with categories. you need to somehow make alternate selection of categories. Because of my small experience in java, my approach to this issue translates into a swollen method of iterating through the entire list and adding a heap of arrays ...