assume that the data structure looks like this:
there are multiple pieces of data, each with an attribute parent (pointing to its own unique identifier id of the parent id), to which it belongs).
class data
parent
id
when I take out one of the pieces of data, I calculate all the subordinate data in one way. Just like the data of China"s administrative region, when I get it in Guangdong Province, I will get it at the city and county level below, and if there are any grades below the county level, I will also get it at the same time.
I wrote some code, which is so ugly that it seems to use recursion. Do you have any good ideas?