def fill_headers(tree, table):
    """
    tree -- header_tree returned from set_headers
    table -- built Table
    return -- col_leaves
    """
    leaves = []
    depth = 0
    current_sweep = tree.children
    while current_sweep:
        cols_to_left = 0
        next_sweep = []
        for node in current_sweep:
            end_col = cols_to_left + node.descendants
            if depth < tree.depth - 1 - node.depth:
                next_sweep.append(node)
                cols_to_left = end_col
            else:
                txt = node.name
                table.set_header_cell(depth, cols_to_left, end_col, txt)
                cols_to_left = end_col
                for child in node.children:
                    next_sweep.append(child)
                if not node.children:
                    leaves.append(node)
        depth += 1
        current_sweep = next_sweep
    return leaves
