private void RestoreDestinationLinks() { var firstUp = ElementsUp.First(); var destinationLinks = NumbersWithConnections[DestinationNumber]; if (ElementsUp.Last().Item1 == destinationLinks.Item1) { destinationLinks = new Tuple <int, int>(firstUp.Item2.Item1, destinationLinks.Item2); } NumbersWithConnections.Add(firstUp.Item1, new Tuple <int, int>(DestinationNumber, firstUp.Item2.Item2)); NumbersWithConnections[DestinationNumber] = new Tuple <int, int>(destinationLinks.Item1, firstUp.Item1); }