Separate out the relevant clash tests and establish which one takes the longest. Are there any nodes which take longer to compute than others? If so, which ones and how long are they executing for? Is is obvious why, I.e. 800,000,000 possible clashes will take around 30 minutes to compute. Are you saying it works in new versions of Revit but not 2017?
Have you also watch the BimorphNodes Element.IntersectsElement video which explains a simple technique for data matching (‘lacing’ for want of better word) the clashing elements between set A and B into groups? I can see you are not doing this which means you are only working with the clash elements (from set B) not the clash group (the element(s) in set B which clash with each element A) which by the sounds of things, is what you need: