def process_hierarchy(rec)
      parent_id = @clades["Mammalia"][:id]
      is_row_rank = false
      %i[order suborder infraorder superfamily family
         subfamily tribe genus subgenus species subspecies].each do |rank|
        is_row_rank = true if rank == rec[:taxonlevel].downcase.to_sym
        clade = rec[rank]
        clade = clade.capitalize if clade =~ /^[A-Z]+$/
        next if clade.to_s == ""
        clade_id = nil
        clade = adjust_clade(rec, rank, clade)
        if @clades.key?(clade)
          clade_id = @clades[clade][:id]
        else
          @count += 1
          clade_id = @count
          @clades[clade] = { id: clade_id, rank: rank }
          @core << [clade_id, nil, parent_id, clade_id, clade, nil, rank.to_s]
          if is_row_rank
            process_name(rec)
            return @core.last
          end
        end
        parent_id = clade_id
      end
    end
def process_hierarchy(rec)
      parent_id = @clades["Mammalia"][:id]
      is_row_rank = false
      %i[order suborder infraorder superfamily family
         subfamily tribe genus subgenus species subspecies].each do |rank|
        is_row_rank = true if rank == rec[:taxonlevel].downcase.to_sym
        clade = rec[rank]
        clade = clade.capitalize if clade =~ /^[A-Z]+$/
        next if clade.to_s == ""
        clade_id = nil
        clade = adjust_clade(rec, rank, clade)
        if @clades.key?(clade)
          clade_id = @clades[clade][:id]
        else
          @count += 1
          clade_id = @count
          @clades[clade] = { id: clade_id, rank: rank }
          @core << [clade_id, nil, parent_id, clade_id, clade, nil, rank.to_s]
          if is_row_rank
            process_name(rec)
            return @core.last
          end
        end
        parent_id = clade_id
      end
    end
rubocop:disable Metrics/AbcSize