Three-way merge implementation in C#