Hey! Please let me know if this is bad practice or in someway a bad thing to do. The thing is in my program I need to make a method which goes through the root element and all child nodes of that element. My elements are like this:
|--ID--|--Parent--|--Additinal info--|
| 1 | 0 | root element |
| 2 | 0 | root elemnet |
| 3 | 1 |child element of 1|
| 4 | 1 |child element of 1|
| 5 | 3 |child element of 3|
--------------------------------------
Now If I want to recieve all children of element with ID 1 (no matter if it has 1000 children or just 2 like in this example) I want my method to bring this too me, but Im not sure how to do it? All of these elements are in a List, and this is what Im working with. For each time I find an element I need to check if it has any children, the same goes with the children. This is because I need to output the elements in correct order. Ive been thinking of maybe make it so I first make a map of the layout, and then use the map for outputting, but Im kinda stuck with the idea.
Any clues?