Hi Vitalii,
Perhaps you can experiment with the Taxonomy parents and children parameters to achieve your goal here. Below are some previous discussions on this topic.
parents
children
If this does not help, it would be helpful to post your current logic and output.