Fix #15073 Infinite loop on empty namespace

Get an infinite loop if types parameter of .remove() has any trailing
dots. Fix is to remove those dots