@BrunoK, nice, thank you. It seems that the DFTRecursive_avk can be simplified without losing performance.
procedure TIntTree.DFTRecursive_avk(aTree: TIntTree; Callback: TTreeNodeCallBack);
procedure Dfs(aNode: TIntNode);
var
I: SizeInt;
begin
Callback(aNode);
for I := 0 to Pred(SizeInt(aNode.Children.Size)) do
Dfs(aNode.Children[I]);
end;
begin
if Assigned(aTree.Root) then
Dfs(aTree.Root);
end;
You can also notice that the above procedures are not completely equivalent, DFTRecursive_avk does not make any assumptions regarding the depth of the tree, but DFTIterative_avk does.