anchor.diff:    if assigned(Node^.Right) then begin
      result^.Right:=CopyNode(Node^.Right);
     end;
  -  if assigned(Node^.Extra) then begin
  -   result^.Extra:=CopyNode(Node^.Extra);
  -  end;
    end else begin
     result:=nil;
  + end;
  +end;
  +
  +// Mark-and-sweep garbage collector for freeing unused nodes
  +procedure TFLRE.FreeUnusedNodes(RootNode:PFLRENode);
  +var Index,Count:longint;
  +    Visited,Stack:TList;
  +    Node:PFLRENode;
  +begin
  + Visited:=TList.Create;
  + try
  +  Count:=0;
  +  Stack:=TList.Create;
  +  try
  +   Stack.Add(RootNode);
  +   while Stack.Count>0 do begin
  +    Node:=Stack[Stack.Count-1];
  +    Stack.Delete(Stack.Count-1);
  +    if assigned(Node) then begin
  +     Visited.Add(Node);
  +     inc(Count);
  +     if assigned(Node^.Left) and (Visited.IndexOf(Node^.Left)<0) then begin
  +      Stack.Add(Node^.Left);
  +     end;
  +     if assigned(Node^.Right) and (Visited.IndexOf(Node^.Right)<0) then begin
  +      Stack.Add(Node^.Right);
  +     end;
  +    end;
  +   end;
  +  finally
  +   Stack.Free;
  +  end;
  +  if Count<>Nodes.Count then begin
  +   Index:=0;
  +   while Index<Nodes.Count do begin
  +    Node:=Nodes[Index];
  +    if Visited.IndexOf(Node)<0 then begin
  +     Node^.Name:='';
  +     Finalize(Node^);
  +     FreeMem(Node);
  +     Nodes.Delete(Index);
  +    end else begin
  +     inc(Index);
  +    end;
  +   end;
  +  end;
  + finally
  +  Visited.Free;
    end;
   end;
   
  
positive.code:    GroupIndexIntegerStack.Free;
     GroupNameStringStack.Free;
    end;
    while assigned(AnchoredRootNode) and OptimizeNode(@AnchoredRootNode) do begin
    end;
    if rfLONGEST in Flags then begin
     UnanchoredRootNode:=NewNode(ntCAT,NewNode(ntSTAR,NewNode(ntCHAR,nil,nil,nil,NewCharClass(AllCharClass)),nil,nil,qkGREEDY),AnchoredRootNode,nil,0);
    end else begin
  
negative.code:          ((((assigned(NodeA) and assigned(NodeB))) and
            ((NodeA^.NodeType=NodeB^.NodeType) and
             ((NodeA^.Value=NodeB^.Value) and
              (AreNodesEqual(NodeA^.Left,NodeB^.Left) and AreNodesEqual(NodeA^.Right,NodeB^.Right))))) or
            not (assigned(NodeA) or assigned(NodeB)));
  end;
  
  