Get latitude/longitude values in python operator

The code snippet I wrote above is the ADD LAT and LON BANDS TO THE PRODUCTS part of the stacking code I created (You can find it here: Error on writing target product).
In that post, that part is commented because the behaviour I got from the bandmaths operator wasn’t as expected (as I was explaining in my post above).