Just create a set of items and try to build a valid tree using ID and parentID. The constraints are very intuitive, just as in a case where you try to build a folder/file structure. There cannot be circular references where a descendant of an item would be referred to as an ancestor of that item.
In the example I gave there is a circ reference because (the first array item) ABC is marked as a child of def, but DEF is then marked as child of abc (the next array item).
Also an indirect circular reference, such as abc > def > ghi > jkl > abc would be invalid too.
If you try to move a folder into any of its descendants, OS would give you an error message. So this explains the constraint: use parentID from within a set of ID, but in such a way only that the reference don't form a circle.