https://sd.blackball.lv/en/articles/read/18930-linq-how-to-avoid-nested-loops-in-csharp?tag=csharp