Google Cloud Interview Question

Make tree flat and invert