Multiple recursion in data structure