When an object has a Rigidbody, calling AddComponent<Rigidbody>() will return null and it will also log a warning message in Console: "The component Rigidbody can't be added because GameObject already contains the same component." Same thing happens when the object has an Image and we call AddComponent<Text>().
In my editor script, I don't want the warning message to appear in the console if AddComponent fails, so I need to find a way to check if AddComponent will fail for the given component type. In which case, I'll simply not call AddComponent at all. I couldn't find an Editor API for this query but it's possible that I've missed some internal APIs.