<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _purge_expired(self):
 """ Remove all expired entries from the cache that do not have a reference count. """

        time_horizon = time.time() - self._keep_time
        new_cache = {}
        dec_count_for = []
        for (k, v) in self._cache.items():
            if v.count > 0:
                if k not in self._block_store:
                    new_cache[k] = v
                else:
                    if v.timestamp > time_horizon:
                        new_cache[k] = v
                    else:
                        block = v.value
                        if block is not None:
                            dec_count_for.append(block.previous_block_id)

            elif v.timestamp > time_horizon:
                new_cache[k] = v

            else:
                block = v.value
                # Handle NULL_BLOCK_IDENTIFIER
                if block is not None:
                    dec_count_for.append(block.previous_block_id)

        self._cache = new_cache
        for block_id in dec_count_for:
            if block_id in self._cache:
                self._cache[block_id].dec_count()