private static void CreateLayerCall(XNodeIn source, XNodeIn dest) { var sourceChain = source.GetParentChain(); var destChain = dest.GetParentChain(); for (int i = 0; i < sourceChain.Length; i++) for (int x = 0; x < destChain.Length; x++) if (sourceChain[i] == destChain[x]) { if (i == 0 || x == 0) { LogError(string.Format("Error trying to find common link between {0} and {1}, common had 0 index", sourceChain[i].Name, destChain[x].Name)); return; } var sourceLayer = sourceChain[i - 1]; var destLayer = destChain[x - 1]; if (sourceLayer.LayerOut == null) sourceLayer.LayerOut = new HashSet<int>(); if (destLayer.LayerIn == null) destLayer.LayerIn = new HashSet<int>(); sourceLayer.LayerOut.Add(destLayer.ID); destLayer.LayerIn.Add(sourceLayer.ID); return; } }