def can_merge(a, b):
    """
    Test if two cubes may be merged into a single cube (their bounding box)
    :param a: cube a, tuple of tuple ((min coords), (max coords))
    :param b: cube b, tuple of tuple ((min coords), (max coords))
    :return: bool, if cubes can be merged
    """
    c = 0  # Count the number of continued dimensions
    for i, j, k, l in zip(a[0], a[1], b[0], b[1]):
        x = i == k and j == l  # If this dimension matches exactly
        y = i == l or j == k  # If one cube continues the other
        z = y and (c == 0)  # If we are the first dimension to be continued
        if not x and not z:
            return False
        if y:  # Increment the continued dimension count
            c += 1
    return True