This has some really rank code smell.  I know you didn't write the original, and it's probably not worth whatever effort it would take to get rid of this branching based on the object type, but this seems like a bit of code that should at least be tested thoroughly (with each of the possible data types that it could end up running against).  I don't immediately see a place in your tests where this is getting coverage.