Copied consistency checking code from openstates4j.