How can I add a Table of Contents to a Keynote presentation that shows pages and titles in some hierarchy.
Assuming one is using Keynote 6 (OP did not state version used.), one way to create a Table of Contents or Handout is to use the Print dialog.
This can be printed to PDF for handouts. One way to customize would be to create a duplicate copy of your presentation then edit the copy before printing the outline.
Edit After printing the outline to PDF, one can create a new slide at the beginning of the presentation and insert the PDF outline onto the slide.
So far, this is the best solution I've found, and AppleScript: http://gingerbbm.com/2012/08/keynote-table-of-contents/
To get it working, save your keynote document in your "Documents" folder and update the script with your documents' name.
Make sure you check out the comments at the bottom, I've described how to make the ToC work with your Slide's titles (as opposed to slide notes, which are the default).
If you have a more recent version of Keynote than the one mentioned in the gingerbbm.com article, you can look at the AppleScript and Keynote pages over at macosxautomation.com