displaytree.py

# =========================================================
# display a tree's node values in ascending order
# =========================================================

import createtree as t

def DisplayTree(node):

    if node.getLess() != None:
        DisplayTree(node.getLess())

    print(node.getData())

    if node.getMore() != None:
        DisplayTree(node.getMore())
 
    return
    
# ---------------------------------------------------------
# main
# ---------------------------------------------------------

theTree = t.Tree()             # create an empty tree

t.createTree(theTree)          # add nodes to the tree

if theTree.getRoot() == None:
    print('the tree is empty')

DisplayTree(theTree.getRoot())