Horrible code, but three way merge working for simple recursive cases