I need help trying to search the nodes of the tree component.  I got partial help a couple of days ago, but the sample code provided was not right.  In the standard treeview component the ALL of nodes exist in an array, which makes searching the whole thing very easy.  Your nodes are in a linked list.

I know I have to use recursion, but I cannot make it work.  I keep getting stack overflow errors.  I tried to use the sample code (listed at the end), but it had no calls to GetNextChild.  How can it work without calling that routine?  I tried to make sense of it, but was only able to make it work one level deep.

I know this is outside the normal scope of support, but I do not know where else to get help.  I need a function that will find a node by matching its Tag value.  When I load the tree data I set the Tag value to the RecordID of the node being added.  If a new node has a parent node, I need to call a function with the parent node ID that either returns the node or nil.  Is any of that even possible?

Here is what I was given to work from:

    N: TAdvTreeNode;
    N := TIWAdvTreeView1.Items.GetFirstNode;
    while (N <> nil) do
      N := N.getNextSibling;

function RetrieveChildNodes(Node: TAdvTreeNode): string;
var  ExN: TAdvTreeNode;
  if not Assigned(Node) then

  ExN := Node.getFirstChild;
  if Assigned(ExN) then
    while (ExN <> nil) do
       OutputDebugString(pchar('item tag: ' + IntToStr(ExN.Tag)));
        ExN := ExN.getNextSibling;

Please have a look at my reply in your previous Topic.