I've got a tree which is populated by Node
objects. Each node has an ArrayList which stores its children nodes as there can be an unspecified amount of children, unlike in a binary tree.
How can I traverse the tree to find a specific node if each node has a number of children, where each child has its own children in turn, and so on. I'm just looking for a generic way of doing this iteratively, for example using a function which searches through a node's arrayList (storing children), and each child's subsequent children's array lists too.
Any suggestions?
UPDATE
This is what I've tried so far:
return
(
(StrangeNode)current.ChildrenList
.SingleOrDefault(c =>
c.GetType().Name.ToString().Equals("StrangeNode"))
).myArrayList;