def _get_past_future_sweep(present_lidarpc: LidarPc, sweep_idx: int) -> LidarPc:  # type: ignore
    """
    Find a past or future sweep given the present sweep and its index.
    :param present_lidarpc: The present sweep.
    :param sweep_idx: The sweep index.
        - Negative numbers corresponding to past sweeps.
        - 0 corresponding to the present sweep.
        - Positive numbers corresponding to future sweeps.
    :returns: The specified sweep or None if we hit the start or end of an extraction.
    """
    # Initialize with present sweep. If sweep_idx == 0, we return it.
    cur_lidarpc = present_lidarpc
    for _ in range(abs(sweep_idx)):
        # Positive sweep index means future sweeps
        if sweep_idx > 0:
            if cur_lidarpc.next is None:  # type: ignore
                return None
            else:
                cur_lidarpc = cur_lidarpc.next  # type: ignore

        # Negative sweep index means past sweeps
        elif sweep_idx < 0:
            if cur_lidarpc.prev is None:  # type: ignore
                return None
            else:
                cur_lidarpc = cur_lidarpc.prev  # type: ignore

    return cur_lidarpc