def getminmax(coords):
    """
    Given an iterable of (x, y), return minx, miny, maxx, maxy.
    """
    i = iter(coords)
    try:
        x, y = i.next()
        minx = maxx = x
        miny = maxy = y
    except StopIteration:
        return None, None, None, None

    for x, y in i:
        if x < minx:
            minx = x
        if x > maxx:
            maxx = x
        if y < miny:
            miny = y
        if y > maxy:
            maxy = y

    return minx, miny, maxx, maxy