The nature of the lithium rich giants. mixing episodes on the rgb and early-agb