Fix for the XMLSerializer bug 18558

* Find the type map element that is the most-specific to the
  object in question rather than the first type it is an instance of

Change-Id: I1867e790bf9f377ce0ae02871f4561b760e27624