Connect dimension lines referencing the same elements with detail line

Good afternoon,

I am pretty new with Dynamo, I need someone to point me into the right direction.
I am trying to make a script that connects dimension lines that reference the same elements.
In the screenshot below I am trying to make the red lines with a script.
Does anyone know which nodes to use? And how to determine which dimension lines are referencing the same set of elements?