prevent infinite loop in pathfinder reports

http://manage.dimagi.com/default.asp?122860
Merge pull request #3827 from dimagi/pathfinder-fix

prevent infinite loop in pathfinder reports