```
from collections import deque
class Solution(object):
def rightSideView(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if not root: return []
queue, rList = deque(), []
queue.append(root)
while queue:
items = len(queue)
for i in range(items):
node = queue.popleft()
if i == items-1: rList.append(node.val)
if node.left: queue.append(node.left)
if node.right: queue.append(node.right)
return rList
```