You can use something like:
(.+?)(?: AND \1)+
then you need only to replace with the content of the first capturing group.
Note that you can add (?s)
at the begining of the pattern to allow the dot to match newlines.
Here is a more waterproof pattern:
(?s)(.+?)(?:\s+AND\s+\1)+
To remove possible parenthesis around an expression, you can use:
(?s)(\(\s*)(.+?)(?:\s+AND\s+\2)+(?(1)\s*\))
Note that you must apply this replacement several times (until there is no more matches) to obtain the result you want, since you can have overlapping matches. Example:
(((p OR q) AND (p OR q)) AND ((p OR q) AND (p OR q)))