code: def _GetPathSegmentIndexForValueWeights(self, value_weights):
      
      largest_weight = value_weights.GetLargestWeight()
  
      if largest_weight > 0:
        value_weight_indexes = value_weights.GetIndexesForWeight(largest_weight)
      else:
        value_weight_indexes = []
  
      if value_weight_indexes:
        path_segment_index = value_weight_indexes[0]
      else:
        path_segment_index = value_weights.GetFirstAvailableIndex()
  
      if path_segment_index is None:
        raise RuntimeError('No path segment index found.')
  
      return path_segment_index
docs: Retrieves the index of the path segment based on value weights.
  
      Args:
        value_weights: the value weights object (instance of _PathSegmentWeights).
  
      Returns:
        An integer containing the path segment index.
  
      Raises:
        RuntimeError: is no path segment index can be found.