https://jason-down.com/2016/09/02/recursion-and-pattern-matching/