Problem with GetTopLevelParent() (not working always)

Working on Windows XP, it happens sometimes that I get an AttributeError with GetTopLevelParent() (the message is «The object has no attribute ‘GetTopLevelParent’»).
Any idea?