Trouble with buildElementQuery customization
I finally found that my problem was a SQL one not a CMS one. The where conditions grouping were the source of the problem. 

Here is the final code I used.

https://gist.github.com/nicolasbinet/7e3835b13c3e9c21d2fa754243242b41