recursively finding children

def nflatten(depth, result = [])
  return [] if depth <= 0
  self.inject([]) { |result, item| result << item << nflatten(depth-1, item);
result }
end