def GetNextQtnodeBounds(qtnode, x, y, size):
  """Calculate next level boundary for qtnode.

  If the qtnode has further precision, call this routine
  recursively.

  Args:
    qtnode: The remaining string of the qtnode.
    x: Current left of the qtnode (degrees).
    y: Current bottom of the qtnode (degrees).
    size: Current size of sides of qtnode (degrees).
  Returns:
    List of lower left and upper right boundary.
  Raises:
    Exception: if qtnode is not well formed.
  """
  if qtnode:
    size /= 2
    if qtnode[0] == "3":
      return GetNextQtnodeBounds(qtnode[1:], x, y + size, size)
    elif qtnode[0] == "2":
      return GetNextQtnodeBounds(qtnode[1:], x + size, y + size, size)
    elif qtnode[0] == "1":
      return GetNextQtnodeBounds(qtnode[1:], x + size, y, size)
    elif qtnode[0] == "0":
      return GetNextQtnodeBounds(qtnode[1:], x, y, size)
    else:
      raise Exception("Error: unexpected qtnode value %s" % qtnode[0])
  else:
    return [x, y, x + size, y + size]