Implement "getchains" RPC command to monitor blockchain forks.

Port over https://github.com/chronokings/huntercoin/pull/19 from
Huntercoin:  This implements a new RPC command "getchains" that can be
used to find all currently active chain heads.  This is similar to the
-printblocktree startup option, but it can be used without restarting
just via the RPC interface on a running daemon.
I think that the STL doesn't use the '==' at all in sort, it considers elements to be the same if neither "a < b" nor "b < a".  But I can't guarantee that it keeps two "equal" elements by themselves, rather than copying one of them two times - I believe not, but I'll change the code to include ordering of the pointers as a secondary criterion to be safe.