Well here's the AP scan code for the Intel WiFi driver: https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes.git/tree/net/wireless/scan.c
Go though the occurrences of SSID
and decide whether you need to add some code to check it before continuing for each one.
Then you can either compile a whole new kernel, or setup dkms to dynamically load the module in.