Sync up the two implementation of Database<>::LatestTreeHead.

Also use the CHECK family of macros instead of assert(), to make sure they
are always active (if one of these things aren't true, something is very,
very wrong!).
Strengthen a few things in LogLookup<>.