<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _add(self, frame, strict):
 """Add a frame. Args: frame (Frame):
 the frame to add strict (bool):
 if this should raise in case it can't be added and frames shouldn't be merged. """


        if not isinstance(frame, Frame):
            raise TypeError("%r not a Frame instance" % frame)

        orig_frame = frame
        frame = frame._upgrade_frame()
        if frame is None:
            if not strict:
                return
            raise TypeError(
                "Can't upgrade %r frame" % type(orig_frame).__name__)

        hash_key = frame.HashKey
        if strict or hash_key not in self:
            self[hash_key] = frame
            return

        # Try to merge frames, or change the new one. Since changing
        # the new one can lead to new conflicts, try until everything is
        # either merged or added.
        while True:
            old_frame = self[hash_key]
            new_frame = old_frame._merge_frame(frame)
            new_hash = new_frame.HashKey
            if new_hash == hash_key:
                self[hash_key] = new_frame
                break
            else:
                assert new_frame is frame
                if new_hash not in self:
                    self[new_hash] = new_frame
                    break
                hash_key = new_hash