```
"""
do level order traversal. While doing traversal returns depth of the first encountered leaf node
"""
class Solution(object):
def minDepth(self, root):
q = []
depth = 0
if root == None:
return depth
q.append(root)
while q:
depth += 1
for _ in range(len(q)):
node = q.pop()
if node.left == None and node.right == None:
return depth
if node.left:
q.insert(0, node.left)
if node.right:
q.insert(0, node.right)
```