At the moment I do not know how to implement my idea.
I will try to describe the algorithm.
Have intersection edges.
Finding the center of the edges (E-> S0)
Recalculate the normals.
Create circles parallel edges (which are connected in the center)
And connect them to the pipe
It seems to me that this method can allow to create a pipe without self-intersection (since they can intersect only in the center)
An example is shown on a simple object, but I tried partially on complex ones (on which current methods do not work) and this should work.