Deleted some ugly code

Deleted copy+paste code Java->Python since I do not want to use it
anymore. There are other readable solutions in Python.