public static Tuple <Type, IEnumerable <Type> > GetCommonBases(Type left, Type right) { var tree = new TypeTree(left); tree.Add(right); var findLeft = tree.Find(left); var findRight = tree.Find(right); var commonInterfaces = findLeft.Interfaces.Select(i => i.Value) .Intersect(findRight.Interfaces.Select(i => i.Value)) .Distinct(); var leftStack = new Stack <TypeTree>(); var temp = findLeft; while (temp != null) { leftStack.Push(temp); temp = temp.Parent; } var rightStack = new Stack <TypeTree>(); temp = findRight; while (temp != null) { rightStack.Push(temp); temp = temp.Parent; } var zippedPaths = leftStack.Zip(rightStack, Tuple.Create); var result = zippedPaths.TakeWhile(tup => tup.Item1.Value == tup.Item2.Value).Last(); return(Tuple.Create(result.Item1.Value, commonInterfaces)); }