t = { "contents" : 6,
      "left"  : { "contents" : 3,
                  "left"  : { "contents" : 8,
                              "left"  : None,
                              "right" : None },
                  "right" : { "contents" : 7,
                              "left"  : None,
                              "right" : None } },
      "right" : { "contents" : 2,
                  "left"  : None,
                  "right" : { "contents" : 9,
                              "left"  : None,
                              "right" : None } } }

###

def getChildren(t):
    children = [ ]
    print("t:", t)
    leftT = t["left"]
    print("leftT:", leftT)
    if leftT != None:
        children.append(leftT["contents"])
    rightT = t["right"]
    print("rightT:", rightT)
    if rightT != None:
        children.append(rightT["contents"])
    return children

###

def countNodes(t):
    print(t)
    if t["left"] == None and t["right"] == None:
        return 1
    else:
        count = 0
        if t["left"] != None:
            count += countNodes(t["left"])
        if t["right"] != None:
            count += countNodes(t["right"])
        return count + 1

###

def countNodes(t):
    print(t)
    if t == None:
        return 0
    else:
        count = 0
        count += countNodes(t["left"])
        count += countNodes(t["right"])
        return count + 1

###

def sumNodes(t):
    if t == None:
        return 0
    else:
        return t["contents"] + sumNodes(t["left"]) + \
               sumNodes(t["right"])

###

def listValues(t):
    if t == None:
        return []
    else:
        leftValues = listValues(t["left"])
        rightValues = listValues(t["right"])
        rootValue = [ t["contents"] ]
        return leftValues + rootValue + rightValues
        