Detect and (recursively) remove head and tail wrappings around the input string
codsen.com/os/string-remove-duplicate-heads-tails
codsen/codsen