Refactor extract_tt_fields from Tpda3/Generator.

Thanks to Borodin from stackoverflow.