Pathex - a library for performing fast actions with nested data structures

Try using Pathex.at/3 like this

Pathex.at(stuff, path(:key2) ~> star() ~> matching(%{foo3: _}), &Map.take(&1, [:foo, :foo2]))