sort predicate to have nodes sorted in Depth First Search order
问题 I have a list of nodes, where each of the nodes belong to one or multiple trees. (they do not necessarily share a common ancestor) I want to sort the nodes in the same order I would find them when doing a Depth First Search. Let say I have a predicate for sorting tree roots together, and another predicate to sort children of a common parent together. Each node have a Parent accessor, and a children enumerator. I want to avoid using the Children enumeration for performance reasons (if possible