def get_future_timestamp(idx, timestamps):
 if (idx == (len(timestamps) - 1)):
  return get_past_timestamp(idx, timestamps)
 elif timestamps[idx]:
  return timestamps[idx][0]
 else:
  idx = min(len(timestamps), (idx + 1))
  return get_future_timestamp(idx, timestamps)

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