def LongValueFromJsonStats(json_stats, keys):
  """Get long integer value from stats with iterating keys.
  For example: when keys = ['stats', 'timeStats', 'uptime'], this returns
  long(json_stats['stats']['timeStats']['uptime']) if any.

  Args:
    stats: json
    keys: iterable keys

  Returns:
    long value if any. None otherwise.
  """
  curr = json_stats
  for k in keys:
    if not curr or k not in curr:
      return None
    curr = curr[k]
  if not curr:
    return None
  return int(curr)