def get_camn(results, cam, remote_timestamp=None, frame=None):
    """helper function to get camn given timestamp or frame number

    last used 2006-05-17

    """
    if not isinstance(cam, str):
        camn = cam
        return camn
    this_cam_id = cam
    possible_camns = []
    for row in results.root.cam_info:
        if row['cam_id'] == this_cam_id:
            possible_camns.append(row['camn'])
    table = results.root.data2d_camera_summary
    for row in table.where('cam_id==this_cam_id'):
        camn = None
        if row['camn'] in possible_camns:
            if remote_timestamp is not None:
                if row['start_timestamp'] <= remote_timestamp <= row[
                    'stop_timestamp']:
                    if camn is not None:
                        if camn != row['camn']:
                            raise RuntimeError(
                                'Found camn already! (Is frame from different run than timestamp?)'
                                )
                    camn = row['camn']
            if frame is not None:
                if row['start_frame'] <= frame <= row['stop_frame']:
                    if camn is not None:
                        if camn != row['camn']:
                            raise RuntimeError(
                                'Found camn already! (Is frame from different run than timestamp?)'
                                )
                    camn = row['camn']
    if camn is None:
        raise RuntimeError('could not find frame or timestamp')
    return camn
