You can now use the :has() pseudo-class to achieve this.
.wrapper:has(.child2) { color: red; }
Refer to https://caniuse.com/css-has to check if your target browser supports it.