def _group_overlapping_images(
        self, image_elements: List[ImageElement], buffer: float = 1.0
    ) -> List[List[ImageElement]]:
        """Group images that overlap or are adjacent."""
        groups = []
        used = set()

        for i, elem1 in enumerate(image_elements):
            if i in used:
                continue
            group = [elem1]
            used.add(i)
            queue = [elem1]
            while queue:
                current = queue.pop()
                for j, elem2 in enumerate(image_elements):
                    if j in used:
                        continue
                    if current.overlaps(elem2, buffer=buffer):
                        group.append(elem2)
                        used.add(j)
                        queue.append(elem2)
            groups.append(group)
        return groups
Group images that overlap or are adjacent.
src/openparse/processing/basic_transforms.py