check parents existence first

http://manage.dimagi.com/default.asp?138679