Try scanning through the list, calculating the maximum:
text_width + indent_size * indent_level + image_width
one iteration over the list should lead to a pretty good estimate of the width of the tree. You might want to iterate over all nodes or only visible nodes depending on your application.
source
share