Check flatten method for possible optimizations, should it be rewritten without recursive calling
Check flatten method for possible optimizations, should it be rewritten without recursive calling