Replace direct type comparison with isinstance comparison.

This is more pythonic, because isinstance compares not only against
given type, but also again all its descendants.

Change-Id: I018ac057980ab2401d3916ac487566995ac877e0