If you have some programming experience, fixing the tech tree pipes isn't that hard - just frustrating. The hardest part is trying to figure out what Firaxis are actually doing in their code. Rather than devise an algorithm that works for any Y1 and Y2 values, they have a huge if then elseif ... else end block, and the problem for modders occurs when you run off the end of the block becuase your abs(Y2-Y1) is greater than the value they were expecting.
There are three approaches to the solution
1) Just add more elseif blocks
2) Re-write their if then else end block into a single function that works for any Y1 and Y2 values
3) Ditch their entire tech tree code and roll-your-own
1) is the easiest, but you now have to decide on the max Y delta you want to support. Any updates to the original code should be just a case of copying over your changes
2) is the most flexible and could be used by any other mod, but you will have to redo your work everytime Firaxis update that section of the code
3) is only really recommended if you are changing the tech buttons as well (eg making them narrower but longer). If you want to take this route, see my
UI - Promotion Tree mod, specifically the PipeManager and ButtonManager lua files
Edit: I should probably add that I would not consider TechTree.lua a good file to start your UI modding with!