f x children sals = concat $ (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) : (foldr (:) [] ((\x -> f x children sals) `map` (children ! x)))
f x children sals = concat $ (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) : (foldr (:) [] ((\x -> f x children sals) `map` (children ! x)))
f x children sals = concat $ (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) : (foldr (:) [] ((\x -> f x children sals) `map` (children ! x)))