'Sort page into regions and columns'

def first_pass(self):

    self.regions = []
    if (not self.elements):
        return
    for (i, x) in enumerate(self.elements):
        x.idx = i
    current_region = Region(self.opts, self.log)
    processed = set([])
    for x in self.elements:
        if (x in processed):
            continue
        elems = set(self.find_elements_in_row_of(x))
        columns = self.sort_into_columns(x, elems)
        processed.update(elems)
        if (not current_region.contains(columns)):
            self.regions.append(current_region)
            current_region = Region(self.opts, self.log)
        current_region.add(columns)
    if (not current_region.is_empty):
        self.regions.append(current_region)
    if (self.opts.verbose > 2):
        self.debug_dir = ('page-%d' % self.number)
        os.mkdir(self.debug_dir)
        self.dump_regions('pre-coalesce')
    self.coalesce_regions()
    self.dump_regions('post-coalesce')
