classNode:def__init__(self,key):self.data=keyself.left=Noneself.right=None#Function to print nodes at distance k from root of the treedefkdistantnode(root,k):ifrootisNone:return0ifk==0:returnroot.dataelse:kdistantnode(root.left,k-1)kdistantnode(root.right,k-1)#Driver program to test above functionroot=Node(1)root.left=Node(2)root.right=Node(3)root.left.left=Node(4)root.left.right=Node(5)root.right.left=Node(8)kdistantnode(root,2)