def _IsNonIncreasing(result, val):
  """Determines if result would be non-increasing if val is appended.

  Args:
    result: list integers and/or range tuples.
    val: integer or range tuple to append.
  Returns:
    bool indicating if the appended list is non-increasing.
  """
  if result:
    if isinstance(result[-1], tuple):
      # extract high from previous tuple
      prev = result[-1][1]
    else:
      # previous is int
      prev = result[-1]
    if val <= prev:
      return True
  return False