refactored to use streams instead of recursion, only one failing test left
finished refactoring: use streams instead of recursion