Happy to help where I can. So with a target value of 2, your script will only detect AiMesh nodes, and not APs/repeaters. If the script is designed to work on APs/Repeaters, than you should also allow values of 3.
Maybe something to test at some point? Unless of course you already know how it...