def merge_stacks(
    s1: Iterable[FrameType], s2: Sequence[FrameType]
) -> Sequence[FrameType]:
    """
    Assuming `s1` is a subset of `s2`, combine the two stacks in presumed call
    order.
    """

    ret = []

    for f in s1:
        ret.append(f)
        try:
            s2i = s2.index(f)
            for _ in range(s2i):
                ret.append(s2[0])
                s2 = s2[1:]
        except Exception:
            pass

    return ret

    Assuming `s1` is a subset of `s2`, combine the two stacks in presumed call
    order.
    
src/core/trulens/core/utils/python.py