Fix a bug of demoting a root.
Replace NullPointerException with IllegalArgumentException