Extract private Task.get_dup_and_gap method