Any nonconforming structure or portion thereof declared unsafe by a proper authority may be restored to a safe condition unless otherwise prevented by law.