Querrying nested documents

I have a tree structure and each parent can have 0 or more children and each child can have 0 or more children. I have implemented it in MongoDB using array of nested documents.
How do you query nested documents made of arrays of nested documents.