'Takes a parent_type and returns the appropiate checkParentDecorator,
a function that takes another function (most probably you are using
it for the __add method) and checks if the object as a parent of
parent_type before adding it.'

def _checkParent(self, parent_type):

    def checkParentDecorator(add_func):
        @wraps(add_func)
        def addWrapper(new_obj, parent_id=None, *args):
            parent = self.mappers_manager.find(parent_type, parent_id)
            if parent:
                add_func(new_obj, parent_id, *args)
            else:
                msg = ('A    parent    is    needed    for    %s    objects' % new_obj.class_signature)
                getLogger(self).error(msg)
                return False
        return addWrapper
    return checkParentDecorator
