Check for parent not being None

We can get a function here as well which will have no parent, see
issue #25.