def snitch_last_contained(metadata):
    """Return the frame when snitch was last contained."""
    last_contain = 0
    for _, movements in metadata['movements'].items():
        contain_start = False
        for movement in movements:
            if movement[0] == '_contain' and movement[1] == 'Spl_0':
                # Should not be containing anything already
                contain_start = True
            elif contain_start and movement[0] == '_pick_place':
                last_contain = max(movement[-2], last_contain)
                contain_start = False
        if contain_start:
            # It never ended
            last_contain = 300  # Max frames
    return last_contain