Is it reasonable to consider a book's table of contents as a hierarchical collection? if yes, what does the root node represent?
The root node is the entire book.
Its children are chapters.
Their children are sections. And so on.

This is reflected in the standard numbering system, in which chapters are labeled by numbers, sections are labeled by numbers within chapters, and so on.

As an example, we can take the table of contents of the book you mention. The root has 15 children: an introduction, 12 chapters, an appendix, and the index. The first child (introduction) is a leaf. The second child has 9 children, which are the various sections: basic program elements, control statements, and so on. The first child (basic program elements) has 19 children, all leaves: programs and modules, an example python program, and so on.