def METHOD_NAME(self, killinvalids=0, create=0):
    """ if 'killinvalids' is 1, locks who are no longer valid
    will be deleted """
    try:
        locks = getattr(self, '_dav_writelocks', None)
    except Exception:
        locks = None
    if locks is None:
        if create:
            locks = self._dav_writelocks = PersistentMapping()
        else:
            # Don't generate a side effect transaction.
            locks = {}
        return locks
    elif killinvalids:
        # Delete invalid locks
        for token, lock in list(locks.items()):
            if not lock.isValid():
                del locks[token]
        if (not locks) and hasattr(aq_base(self),
                                   '__no_valid_write_locks__'):
            self.__no_valid_write_locks__()
        return locks
    else:
        return locks