First commit contains recursive implementation of the algorithm
Performance test showed that time complexity increased exponentially when number of elements was increased (for deep structures)
1000 elements - 00:00:00.0194165
5000 elements - 00:00:00.4333768
This article explains possible performance problems with yield return
operator
So the implementation has been changed to non recursive, please see here
Time complexity became linear
1000 elements - 00:00:00.0020284
5000 elements - 00:00:00.0023037