private static CategoryEntry GetDeepestMatch( CategoryEntry root, Type type )
{
if( !root.IsMatch( type ) )
return null;
for( int i = 0; i < root.SubCategories.Length; ++i )
{
CategoryEntry check = GetDeepestMatch( root.SubCategories[i], type );
if( check != null )
return check;
}
return root;
}