Move Python's isUsefulType and mergeType utility functions upstream

Ruby and qmljs need them too, so it would be good not to have three copies.
CCMAIL:steckdenis@yahoo.fr
Fix an obvious mistake in the type merging function

it used the pointers refcount instead of the amount of types. heh.
Arguably this is because the API naming sucks.
Thanks to denis for finding this.