Simplify path filtering code in tracePaths() a bit, and improve documentation.