TL;DR
When a pipe has mixed fluids and one is just a tiny amount it should get pushed out by the other fluid or destroyed.What ?
When you have a pipe containing less than 10% fluid and a connected pipe has more than 90% fluid the lesser fluid should try to move out of the pipe though one of the other connections. If no fluid can be moved (or less than 0.01 or something) the lesser fluid should be destroyed.Why ?
Fluid mixing is a possibility and even desirable at times. But then fluids get stuck because pipelines can't be pumped completely empty. A small amount of fluid remains with not enough slope for the fluid to flow towards the end. But a new fluid could be pumped into the pipe to either push the remains out or, if some gets trapped, destroy them.This would allow building for example train stations that accept any fluid and sorts the fluid into different outgoing train stations, one per fluid.
Or a station accepting heavy and light oil and sorting them into different holding tanks for cracking into petroleum gas. One wouldn't have to build to train stations for this.