Nacelle-mounted lidar systems offer the possibility of remotely sensing the inflow of wind turbines. Due to the limitation of line-of-sight measurements and the limited number of focus positions, assumptions are necessary to derive useful inflow characteristics. Typically, horizontally homogeneous inflow is assumed which is well satisfied in flat, homogeneous terrain and over sufficiently large time averages. However, it is violated if a wake impinges the field of view of one of the beams. In such situations, the turbine yaw misalignment measurements show large biases which require the detection and correction of these observations. Here, a detection algorithm is proposed based on the spectral broadening of the Doppler spectrum due to turbulence within the probe volume. The small-scale turbulence generated within wake flows will typically lead to a significantly larger broadening than in the ambient flow. Thus, by comparing the spectral widths at several measurement locations, situations where a wake is impinging one or more measurement locations can be identified. The correction method is based on an empirical relationship between the difference in turbulence levels at distinct beams and the difference in wind direction derived from the lidar and the real wind direction. The performance of the algorithm is evaluated in a field experiment identifying all wake situations and, thus, correcting the lidar derived wind direction.