module Sprockets::Utils

def dfs_paths(path)

Returns an Array of node Arrays.

node - Current node to get children of
block -
path - Initial Array node path

TODO: Rename function.

along the way.
Internal: Post-order Depth-First search algorithm that gathers all paths
def dfs_paths(path)
  paths = []
  stack, seen = [path], Set.new
  while path = stack.pop
    if !seen.include?(path.last)
      seen.add(path.last)
      paths << path if path.size > 1
      Array(yield path.last).reverse_each do |node|
        stack.push(path + [node])
      end
    end
  end
  paths
end