     }
 
     private func enumElementsCount(dictionary: [String: SourceKitRepresentable]) -> Int {
-        let enumSubstructure = dictionary["key.substructure"] as? [SourceKitRepresentable] ?? []
-        return enumSubstructure.filter { item -> Bool in
-            guard let subDict = item as? [String: SourceKitRepresentable],
-                let kindString = subDict["key.kind"] as? String,
-                SwiftDeclarationKind(rawValue: kindString) == .enumelement else {
-                    return false
-            }
-
-            guard !filterEnumInits(dictionary: subDict).isEmpty else {
-                return false
-            }
-
-            return true
-        }.count
+        return children(of: dictionary, matching: .enumelement).filter({ element in
+            return !filterEnumInits(dictionary: element).isEmpty
+        }).count
     }
 
     private func violatingOffsetsForEnumCase(dictionary: [String: SourceKitRepresentable],
                                              file: File) -> [Int] {
-        let enumSubstructure = dictionary["key.substructure"] as? [SourceKitRepresentable] ?? []
-        let violations = enumSubstructure.flatMap { item -> [Int] in
-            guard let subDict = item as? [String: SourceKitRepresentable],
-                let kindString = subDict["key.kind"] as? String,
-                SwiftDeclarationKind(rawValue: kindString) == .enumelement,
-                let name = subDict["key.name"] as? String else {
-                    return []
+        return children(of: dictionary, matching: .enumelement).flatMap { element -> [Int] in
+            guard let name = element["key.name"] as? String else {
+                return []
             }
-
-            return violatingOffsetsForEnumElement(dictionary: subDict, name: name, file: file)
+            return violatingOffsetsForEnumElement(dictionary: element, name: name, file: file)
         }
-
-        return violations
     }
 
     private func violatingOffsetsForEnumElement(dictionary: [String: SourceKitRepresentable],

import Foundation
import SourceKittenFramework

public struct RedundantStringEnumValueRule: ASTRule, ConfigurationProviderRule {
    public var configuration = SeverityConfiguration(.warning)


    public static let description = RuleDescription(
        identifier: "redundant_string_enum_value",
        name: "Redudant String Enum Value",
        description: "String enum values can be omitted when they are equal to the enumcase name.",
        nonTriggeringExamples: [
            "enum Numbers: String {\n case one\n case two\n}\n",
            "enum Numbers: Int {\n case one = 1\n case two = 2\n}\n",
