Write a function that processes a stream of numerical sensor data and filters out noise using basic mathematical algorithms such as modulus math or moving averages.
Implement filter_sensor_noise(data, window_size, threshold). Return a new list where each reading that differs from the average of the previous up to window_size filtered readings by more than threshold is replaced by that average; otherwise, retain the reading. The first reading has no prior average and is retained unchanged. Process readings in order without changing the input list.
def filter_sensor_noise(data, window_size, threshold):