def _find_cellid(self, code):
        """Determines the most similar cell (if any) to the specified code. It
        must have at least 50% overlap ratio and have been a loop-intercepted
        cell previously.

        Args:
            code (str): contents of the code cell that were executed.
        """
        from difflib import SequenceMatcher
        maxvalue = 0.
        maxid = None
        
        for cellid, c in self.cellids.items():
            matcher = SequenceMatcher(a=c, b=code)
            ratio = matcher.quick_ratio()
            if ratio > maxvalue and ratio > 0.5:
                maxid, maxvalue = cellid, ratio

        return maxid