How to connect two pipes in the same position into one

I have some vertical pipes, that are in the same horizontal position, but not at the same level. I can move the endpoint to connect them in Revit, so how to do this with dynamo or a script?
001

I usually delete 1 of 2 pipe

Try this one from genius loci
Capture

2 Likes

Perfect! Thanks a lot~