Make filter-map tail-recursive