Fix duplicate items in HABTM associations.
Fix duplicate items in HABTM associations.

Apply patch from 'Kim Biesbjerg'.  Fixes issues where nested
HABTM associations would create duplicate content.

Fixes #2564
Fixes #1598

justinyost/cakephp,tgr0ss/cakephp,garethellis36/cakephp,yinhe007/cakephp,pbaire/cakephp,jeffblack360/cakephp,petteyg/cakephp,berrygoudswaard/cakephp,gmponos/cakephp,ndm2/cakephp,et304383/passbolt_api,pbaire/cakephp,berrygoudswaard/cakephp,nrother/cakephp,CakeDC/cakephp,ionas/cakephp,CVO-Technologies/cakephp,web-player/cakephp,CakeDC/cakephp,jerems02/cakephp,burriko/cakephp,elboletaire/cakephp,davidyell/cakephp,mvdriel/cakephp,bravo-kernel/cakephp,ndm2/cakephp,dkarvounaris/cakephp,tgr0ss/cakephp,michaelze/cakephp,yinhe007/cakephp,jeffblack360/cakephp,michaelze/cakephp,eryw/cakephp,tenkoma/cakephp,dkarvounaris/cakephp,garethellis36/cakephp,CakeDC/cakephp,ADmad/cakephp,tenkoma/cakephp,cakephp/cakephp,thinkingmedia/cakephp,akintoey/cakephp,Balachan27/cakephp,jerems02/cakephp,jjj117/cakephp,CVO-Technologies/cakephp,elboletaire/cakephp,cakephp-fr/cakephp,elboletaire/cakephp,bravo-kernel/cakephp,cakephp/cakephp,erikfig/cakephp,justinyost/cakephp,tgr0ss/cakephp,Phillaf/cakephp,petteyg/cakephp,davidyell/cakephp,dakota/cakephp,tenkoma/cakephp,kumamidori/cakephp,petteyg/cakephp,Balachan27/cakephp,erikfig/cakephp,cakephp/cakephp,timhoeppner/cakephp,eryw/cakephp,CVO-Technologies/cakephp,dakota/cakephp,HavokInspiration/cakephp,gmponos/cakephp,HavokInspiration/cakephp,ADmad/cakephp,nrother/cakephp,khoimt/cakephp-study,justinyost/cakephp,Balachan27/cakephp,ionas/cakephp,jjj117/cakephp,adopico/cakephp,et304383/passbolt_api,tisu2tisu/cakephp,petteyg/cakephp,akintoey/cakephp,yinhe007/cakephp,eboominathan/cakephp,tisu2tisu/cakephp,bravo-kernel/cakephp,jerems02/cakephp,nrother/cakephp,mvdriel/cakephp,pbaire/cakephp,dakota/cakephp,cakephp-fr/cakephp,web-player/cakephp,kumamidori/cakephp,gmponos/cakephp,tisu2tisu/cakephp,erikfig/cakephp,jeffblack360/cakephp,timhoeppner/cakephp,timhoeppner/cakephp,berrygoudswaard/cakephp,burriko/cakephp,michaelze/cakephp,dakota/cakephp,cakephp/cakephp,thinkingmedia/cakephp,eboominathan/cakephp,Phillaf/cakephp,et304383/passbolt_api,eryw/cakephp,cakephp-fr/cakephp,CakeDC/cakephp,mvdriel/cakephp,ndm2/cakephp,ndm2/cakephp,khoimt/cakephp-study,et304383/passbolt_api,garethellis36/cakephp,jjj117/cakephp,et304383/passbolt_api,mvdriel/cakephp,web-player/cakephp,kumamidori/cakephp,adopico/cakephp,thinkingmedia/cakephp,burriko/cakephp,dkarvounaris/cakephp,HavokInspiration/cakephp,davidyell/cakephp,Phillaf/cakephp,khoimt/cakephp-study,ADmad/cakephp,tenkoma/cakephp,garethellis36/cakephp,eboominathan/cakephp,akintoey/cakephp,ADmad/cakephp,adopico/cakephp,ionas/cakephp