'Return the boolean value of a `hasparent` flag attached to
the given state.
The `optimistic` flag determines what the default return value
should be if no `hasparent` flag can be located.
As this function is used to determine if an instance is an
*orphan*, instances that were loaded from storage should be
assumed to not be orphans, until a True/False value for this
flag is set.
An instance attribute that is loaded by a callable function
will also not have a `hasparent` flag.'

def hasparent(self, state, optimistic=False):

    msg = 'This    AttributeImpl    is    not    configured    to    track    parents.'
    assert self.trackparent, msg
    return (state.parents.get(id(self.parent_token), optimistic) is not False)
