Cleanup.
Use a std::set instead of a std::queue when walking the tree to prevent
multiple visits to the same depth-vertex pairs. Duh.