Kia optima flickering headlights

Flickering lights usually means there are some bad diodes inside the alternator. Assuming the replacement alternator is okay there might be a bad connection between the alternator and the positive battery post which would keep the battery from getting a full charge. There should be less than .3 volts across those points while there is a good load on the system if that connection is okay. I assume the battery has already been checked for a problem but if not it needs to be. If those things are okay then the wiring from the battery to the panel under the hood needs to be checked doing a voltage drop test just like the alternator to the battery. The battery to chassis ground needs to be checked also.