Understand the difference between source / mainSource. So
theLayer.source would reveal an item object in the project window.
theItem.mainSource would reveal a type of FootageSource object like a SolidSource. Of course a folder item wouldn't have a mainSource! Potential error there.