def get_positions_at_time(positions, t):
    """
    Return a list of positions (dicts) closest to, but before time t.
    """
    # Assume positions list is already sorted.
    # frame is a list of positions (dicts) that have the same timestamp.
    frame = []
    frame_time = 0.0
    for pos in positions:
        # If we passed the target time t, return the frame we have
        if pos["time"] > t:
            break
        # If this positions is part of the current frame, add it
        if pos["time"] == frame_time:
            frame.append(pos)
        # If current frame is over, make a new frame and add this position to it
        else:
            frame = []
            frame.append(pos)
            frame_time = pos["time"]
    return frame