add more recursive code for reverse or dedup

add more recursive code for reverse or dedup