depth first search in groovy. Pretty clean!