if i had to guess, i'd say that its just less resource intensive or easeier. much easier to just print it out with an indention instead of parsing results into a tree and then printing.
It seems to calculate the image's width to construct indentation. I think it would be easier to just enclose the comments with <dt></dt> and the child trees with <dd></dd>.