When one places a prefab onto the map only coords are changed as seen below.
Vehicle BTR1 : "{C012BB3488BEA0C2}Prefabs/Vehicles/Wheeled/BTR70/BTR70.et" { coords 101.97 0.001 150.739 }
When you then change any component property it saves it like this
Vehicle BTR1 : "{C012BB3488BEA0C2}Prefabs/Vehicles/Wheeled/BTR70/BTR70.et" { components { ControllersManagerComponent "{3524A75DA7DAC1AD}" { Enabled 0 } } coords 101.97 0.001 150.739 }
But if you then undo it in the workbench by using reset to default button
you get this:
Vehicle BTR1 : "{C012BB3488BEA0C2}Prefabs/Vehicles/Wheeled/BTR70/BTR70.et" { components { ControllersManagerComponent "{3524A75DA7DAC1AD}" { } } coords 101.97 0.001 150.739 }
This is a problem because if there is a component override even if it does nothing, the engine will add an additional BaseContainer layer to the entity source, even though it's fully prefabbed again. So it is impossible to detect if any entity is fully prefabbed or if the map layer might have any overrides on it.
The fix is simple, if there is a component override that does nothing aka is empty then remove it. And if the components array has 0 component overrides then it too should be deleted. That way the original form of the map layer is restored again.