Use page.html.twig template variable in another twig template
The book-tree.twig is rendered in its own scope.  It does not "know" any of the context it is being rendered in, so it can't tap into the variables from the page twig per se.  It only gets the variables you give it.  So you could implement a THEME_preprocess_book_tree(&amp;$variables) hook to add it in.  $variables['page_nid'] = // your code here will make it available in twig as {{ page_nid }}.

However at the risk of being "that annoying guy" who tells you not to do things instead of just answering your question


  This variable will be used in a set statement, comparing it to the item.original_link.nid to set an active class.


Personally I would eschew this approach as it ends up placing logic inside the presentation layer.  I would rather use the hook to compare item nids to page nid, and add the active class to that item's attributes as appropriate.  That way the twig can be kept extremely "stupid", and simply dump out whatever attributes for all items, and those attributes will magically contain (or not contain) the appropriate classes.