Check for null parent in recureElement

The check is done elsewhere in this method, it should be done here as
well
Merge pull request #118 from JimiSmith/master

Check for null parent in recurseElement