Recursive loop end

[left]How do i determine the end of a recursive loop - when going through an xml document of unknown size?
[/left]