You can use following code to enumerate through all nodes in DotNetBar for WinForms AdvTree control:

C#:

// Following code enumerates through all nodes and prints out node text to console
foreach (Node node in AllNodes(advTree1.Nodes))
{
    Console.WriteLine(node.Text);
}
 
// This is what makes flat access to tree nodes easy
private static IEnumerable AllNodes(NodeCollection nodes)
{
    for (int i = 0; i<nodes.Count; i++)
    {
        Node node = nodes[i];
        yield return node;
        if (node.Nodes.Count > 0)
        {
            foreach (Node item in AllNodes(node.Nodes))
            {
                yield return item;
            }
        }
    }
}

VB:

' Following code enumerates through all nodes and prints out node text to console
For Each node As Node In AllNodes(advTree1.Nodes)
	Console.WriteLine(node.Text)
Next node
 
' This is what makes flat access to tree nodes easy
Private Shared Iterator Function AllNodes(ByVal nodes As NodeCollection) As IEnumerable
	For i As Integer = 0 To nodes.Count - 1
		Dim node As Node = nodes(i)
		Yield node
		If node.Nodes.Count > 0 Then
			For Each item As Node In AllNodes(node.Nodes)
				Yield item
			Next item
		End If
	Next i
End Function