mtr: Fix #305 by implementing hsearch(3) (#1697)