Check if $parent (title) exists

It's rare cases that it won't exist, except for
in tests if Title gets mocked.

Then this code gets called in hooks and can fail.

Change-Id: Id7d3166a726abae3d75838493ca81a9e68bd1fa7