As I've already mentioned in my previous replies, the itemid is entirely up to the activity in question. So, for example, the 'folder' activity, stores all files in one area per activity, so it leaves the itemid as 0. Forums have multiple posts per activity and each have their own attachments, so the itemid in that case is the id of the mdl_forum_post record.
I couldn't say what itemid the lesson module uses (or even if it uses the itemid), without looking at the code. However, a quick search for a line of code like: $fs = get_file_storage(); within the lesson code would get you to the start of the files processing code, after which it should be fairly easy to track down a call to $fs->get_area_files or $fs->create_file_from_xxx or similar function calls that should be able to show how the itemid is calculated in this case.