Recursion is the way to go in Erlang / Elixir: https://learnyousomeerlang.com/recursion
When one writes a bit if Erlang for a while, one gets a completely different view on any software to be written in the future. Erlang is life changing. But there are things where other technologies are better fit.