I had a problem recently where I had an inheritance hierarchy of which I needed to find a common ancestor type between two objects. Below shows a quick mock up of the situation I faced.

As you can see the Person type is the common ancestor for both Student and Teacher. In order to solve this issue I decided to write the following extension method for the Type type to be able to locate it easily in the future. Code below for anyone interested. Hope it helps.
///
/// Extension methods for the Type
///
public static class TypeExtensions
{
///
/// Finds the nearest common ancestor for a given type.
///
///
public static Type FindCommonAncestor (this Type type, Type targetType)
{
if (targetType.IsAssignableFrom(type))
return targetType;
var baseType = targetType.BaseType;
while(baseType != null && !baseType.IsPrimitive)
{
if (baseType.IsAssignableFrom(type))
return baseType;
baseType = baseType.BaseType;
}
return null;
}
}