This is a sample I've written quickly to solve your problem. As an example, we will be working with US cities finding furthest cities within every state. As you have ArcGIS Desktop installed, you have the necessary data to run the code.
Note that there will be one row less in the output table because District Columbia has only one city. I've also left some comments to help you understand the workflow. The execution time for the code is something under 1 minute (3149 cities in the input feature class).
import os
import arcpy
from arcpy.da import SearchCursor
arcpy.env.overwriteOutput = True
cities = r'C:\Program Files (x86)\ArcGIS\Desktop10.4\TemplateData\TemplateData.gdb\USA\cities'
group_attr = 'STATE_NAME'
scratch_gdb = r'in_memory' #r'C:\GIS\Temp\ArcGISHomeFolder\empty.gdb'
grouping_vals = list(set(f[0] for f in SearchCursor(cities, group_attr))) #'OBJECTID < 20'
lookup = {}
for val in grouping_vals:
print val
#create a feature layer keeping only cities with a specific state
feat_lyr_name = 'cities_lyr_' + val.replace(' ','')
arcpy.MakeFeatureLayer_management(in_features=cities,
out_layer=feat_lyr_name,
where_clause=''' {0} = '{1}' '''.format(group_attr,val))
#count number of cities in the state
group_feature_count = int(arcpy.GetCount_management(in_rows=feat_lyr_name).getOutput(0))
#generate near table for every city in the state (all-to-all)
near_table = os.path.join(scratch_gdb,'near_{}'.format(val.replace(' ','')))
arcpy.GenerateNearTable_analysis(in_features=feat_lyr_name, near_features=feat_lyr_name,
out_table=near_table,
closest='ALL')
#compose a dictionary {source_fid: destination_fid} for only top rank (interested only in furthest)
group_lookup = {f[0]:f[1] for f in SearchCursor(near_table, ['IN_FID','NEAR_FID','NEAR_RANK'],
where_clause='NEAR_RANK = {}'.format(group_feature_count-1),
sql_clause=(None, 'ORDER BY NEAR_RANK DESC'))}
lookup.update(group_lookup)
#inserting new rows into a gdb table
with arcpy.da.InsertCursor(r'C:\GIS\Temp\ArcGISHomeFolder\Default.gdb\DistancesLookup',
['SourceFID', 'DestinationFID']) as cur:
for k, v in lookup.iteritems():
cur.insertRow((k, v))