# encoding=utf-8class node(object): def __init__(self,data,left=None,right=None): self.data = data self.left = left self.right = right tree = node('D',node('B',node('A'),node('C')),node('E',right=node('G',node('F')))) # 先序def front(tree): if tree ==…