def transform_region_to_coordinates(x_coord,
                                    y_coord,
                                    prefix_len,
                                    image_bit_level=10):
    """Transforms (x,y)-bit region into a square for a final level.

    This method converts a leaf on some level `prefix_len` to a square region at
    the final level `2^image_bit_level`. For example, a first leaf on the
    smallest prefix 2x2 will occupy (0:512, 0:512) region of the 10-bit image.

    Args:
      x_coord:
      y_coord:
      prefix_len:
      image_bit_level:

    Returns:
      A square region coordinates.
    """

    shift = image_bit_level - prefix_len
    x_bot = x_coord << shift
    x_top = ((x_coord + 1) << shift) - 1
    y_bot = y_coord << shift
    y_top = ((y_coord + 1) << shift) - 1
    return (x_bot, x_top, y_bot, y_top)