Q:

Most elegant way to get two properties at the same time

Suppose you have hierarchical data and want to obtain the merged value of separate properties, what is the most elegant, or groovy, way to do so?
The following example holds information about failed and skipped tests. Of course, it does make sense, that these values are separated - but for the use case of retrieving a list of all tests, that did not run successfully, I came across two possible solutions, which both of them did not satisfy me.
def junitResultList = [
    [
        name: "Testsuite A",
        children: [
            failedTests: ["Test 1", "Test 2"],
            skippedTests: []
        ]
    ],
    [
        name: "Testsuite B",
        children: [
            failedTests: ["CursorTest"],
            skippedTests: ["ClickTest", "DragNDropTest"]
        ]
    ]
]

To be more specific, I want the value to be ["Test 1", "Test 2", "CursorTest", "ClickTest", "DragNDropTest"].
The first approach was simply to perform an addition of the spread test lists:
(junitResultList*.children*.failedTests + 
 junitResultList*.children*.skippedTests).flatten()

While this works, it appeared to me that specifying the path to these properties twice seems not to be the most groovy way, so I came up with this horrible but somehow appealing disasterpiece:
(junitResultList*.children*.findAll {
    ['skippedTests', 'failedTests'].contains(it.key)
})*.values().flatten()

A:

You can just do as below:
//Define the keys to find
def requiredKeys = ['failedTests', 'skippedTests']
println requiredKeys.collect{ junitResultList.children."$it"}.flatten()

You can quickly try the same online demo

A:

You can simplify your initial expression to something like this:
junitResultList.children.collect { it.failedTests + it.skippedTests }.flatten()

or
junitResultList.children.collect { [it.failedTests, it.skippedTests] }.flatten()

