Check if we can get children before iterating

Fixes #215
Merge pull request #216 from koenhendriks/patch-1

Check if we can get children before iterating