I believe that the Mac App Store finds the old Xcode by searching for the App Store receipt file.
Some people have reported (on Twitter) successfully keeping Xcode 4 by deleting the receipt file in Xcode.app/Contents/_MASReceipt/receipt
before installing Xcode 5 (probably best to just delete the _MASReceipt
directory). Obviously you also need to rename the old Xcode.app
.