def get_past_timestamp(idx, timestamps):
 if (idx == 0):
  return get_future_timestamp(idx, timestamps)
 if timestamps[idx]:
  res = timestamps[idx][(-1)]
  return res
 else:
  return get_past_timestamp((idx - 1), timestamps)

def get_past_timestamp ( idx , timestamps ) : if ( idx == 0 ) : return get_future_timestamp ( idx , timestamps ) if timestamps [ idx ] : res = timestamps [ idx ] [ ( - 1 ) ] return res else : return get_past_timestamp ( ( idx - 1 ) , timestamps )
recursive function to find the most recent valid timestamp in the past .