Reducing redundant code in gromacs_topology_parser