Problem: p02281
Buggy submission (Python3, verdict: Wrong Answer):

N = int(input())
T = [None for i in range(N)]
class Tree:
    def __init__(self, ID,p=-1):
        self.ID = ID

    def makeTree(self, tree):
        ID = tree.ID
        if ID == -1:
            return
        else:
            for i in range(N):
                if trees[i][0] == ID:
                    [ID,l,r] = trees[i]
                    tree.l = Tree(l)
                    tree.r = Tree(r)
                    treeL = tree.l
                    treeR = tree.r
                    treeL.p = tree
                    treeR.p = tree

                    self.makeTree(self,treeL)
                    self.makeTree(self,treeR)

def preParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global preList
        preList.append(ID)
        treeL = tree.l
        treeR = tree.r
        preParse(treeL)
        preParse(treeR)
        
def inParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global inList
        treeL = tree.l
        treeR = tree.r
        inParse(treeL)
        inList.append(ID)
        inParse(treeR)

def posParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global posList
        treeL = tree.l
        treeR = tree.r
        posParse(treeL)
        posParse(treeR)
        posList.append(ID)
        
    
trees = [list(map(int,input().split())) for i in range(N)]
ID = trees[0][0]
tree = Tree(ID)
Tree.makeTree(Tree,tree)

preList = []
inList = []
posList = []
preParse(tree)
inParse(tree)
posParse(tree)

def convert(List, order):
    a =  " " + " ".join([str(num) for num in List])
    print("{}".format(order))
    print(a)
convert(preList, "Preorder")
convert(inList, "Inorder")
convert(posList, "Postorder")


Failing test case input:
9
0 2 4
1 0 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

Expected output:
Preorder
 1 0 2 4 5 6 7 8 3
Inorder
 2 0 6 5 7 4 8 1 3
Postorder
 2 6 7 5 8 4 0 3 1


Actual output:
Preorder
 0 2 4 5 6 7 8
Inorder
 2 0 6 5 7 4 8
Postorder
 2 6 7 5 8 4 0


Fixed submission (verdict: Accepted):

N = int(input())
T = []
class Tree:
    def __init__(self,ID,l=None,r=None,p=-1):
        self.ID = ID
        self.l = l
        self.r = r
        self.p = p

    def makeTree(self):
        for i in range(N):
            T.append(Tree(i))


def preParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global preList
        preList.append(ID)
        preParse(tree.l)
        preParse(tree.r)
        
def inParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global inList
        inParse(tree.l)
        inList.append(ID)
        inParse(tree.r)

def posParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global posList
        posParse(tree.l)
        posParse(tree.r)
        posList.append(ID)
        
    
trees = [list(map(int,input().split())) for i in range(N)]
Tree.makeTree(Tree)
for i in range(N):
    ID,l,r = trees[i]
    tree = T[ID]
    if l != -1:
        T[l].p = tree
        tree.l = T[l]
    if r != -1:
        T[r].p = tree
        tree.r = T[r]
    
for i in range(N):
    if T[i].p == -1:
        parent = T[i]

preList = []
inList = []
posList = []
preParse(parent)
inParse(parent)
posParse(parent)

def convert(List, order):
    a =  " " + " ".join([str(num) for num in List])
    print("{}".format(order))
    print(a)
convert(preList, "Preorder")
convert(inList, "Inorder")
convert(posList, "Postorder")