private static bool EqualSubstitutions([NotNull] ITypeElement referenceOwner, [NotNull] ISubstitution referenceSubstitution, [NotNull] ITypeElement originOwner, [NotNull] ISubstitution originSubstitution) { foreach (var substitution1 in referenceOwner.GetAncestorSubstitution(originOwner)) { var substitution2 = substitution1.Apply(referenceSubstitution); foreach (var typeParameter in substitution2.Domain) { if (originSubstitution.HasInDomain(typeParameter) && !substitution2[typeParameter].IsEquals(originSubstitution[typeParameter])) { return(false); } } } return(true); }