Problem:
A rooted binary tree is a tree with a root node in which every node has at most two children.  Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ :    * node ID of _u_   * parent of _u_   * sibling of _u_   * the number of children of _u_   * depth of _u_   * height of _u_   * node type (root, internal node or leaf)  If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa).  The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.  Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.

Incorrect submission (verdict: Wrong Answer):
import sys

nil = -1

class Node:
    def __init__(self):
        self.parent = nil
        self.sibling = nil
        self.degree = 0
        self.left = nil
        self.right = nil
        self.depth = nil
        self.height = nil
        self.ntype = 'leaf'

def set_depth(v, depth):
    bitree[v].depth = depth

    if bitree[v].left != nil:
        set_depth(bitree[v].left, depth + 1)

    if bitree[v].right != nil:
        set_depth(bitree[v].right, depth + 1)

def set_height(v, height):
    bitree[v].height = height

    if bitree[v].parent != nil:
        if bitree[bitree[v].parent].height < bitree[v].height + 1:
            cur = bitree[v].parent
            i = 1

            while cur != nil:
                bitree[cur].height = height + i
                i += 1
                cur = bitree[cur].parent

n = int(input())
bitree = [Node() for i in range(n)]
leaves = set()

for i in range(n):
    line = [int(j) for j in input().split()]
    t_id = line[0]
    bitree[t_id].left = line[1]
    bitree[t_id].right = line[2]
    bitree[t_id].degree = (line[1] != nil) + (line[2] != nil)

    if bitree[t_id].degree > 0:
        bitree[t_id].ntype = 'internal node'

        if bitree[t_id].left != nil:
            bitree[bitree[t_id].left].parent = t_id

        if bitree[t_id].right != nil:
            bitree[bitree[t_id].right].parent = t_id

        if bitree[t_id].degree == 2:
            bitree[bitree[t_id].left].sibling = bitree[t_id].right
            bitree[bitree[t_id].right].sibling = bitree[t_id].left
    else:
        leaves.add(t_id)

for t_id in range(n):
    if bitree[t_id].parent == nil:
        bitree[t_id].ntype = 'root'
        r = t_id
        break

set_depth(r, 0)

for leaf in leaves:
    set_height(leaf, 0)

for t_id in range(n):

    print('node {}: parent = {}, subling = {}, degree = {}, depth = {}, height = {}, {}'.format(
            t_id, bitree[t_id].parent, bitree[t_id].sibling, bitree[t_id].degree,
            bitree[t_id].depth, bitree[t_id].height, bitree[t_id].ntype))

Fixed, accepted submission:
import sys

nil = -1

class Node:
    def __init__(self):
        self.parent = nil
        self.sibling = nil
        self.degree = 0
        self.left = nil
        self.right = nil
        self.depth = nil
        self.height = nil
        self.ntype = 'leaf'

def set_depth(v, depth):
    bitree[v].depth = depth

    if bitree[v].left != nil:
        set_depth(bitree[v].left, depth + 1)

    if bitree[v].right != nil:
        set_depth(bitree[v].right, depth + 1)

def get_height(v):
    h1 = 0
    h2 = 0

    if bitree[v].left != nil:
        h1 = get_height(bitree[v].left) + 1
    if bitree[v].right != nil:
        h2 = get_height(bitree[v].right) + 1

    bitree[v].height = max(h1, h2)

    return bitree[v].height

n = int(input())
bitree = [Node() for i in range(n)]
leaves = set()

for i in range(n):
    line = [int(j) for j in input().split()]
    t_id = line[0]
    bitree[t_id].left = line[1]
    bitree[t_id].right = line[2]
    bitree[t_id].degree = (line[1] != nil) + (line[2] != nil)

    if bitree[t_id].degree > 0:
        bitree[t_id].ntype = 'internal node'

        if bitree[t_id].left != nil:
            bitree[bitree[t_id].left].parent = t_id

        if bitree[t_id].right != nil:
            bitree[bitree[t_id].right].parent = t_id

        if bitree[t_id].degree == 2:
            bitree[bitree[t_id].left].sibling = bitree[t_id].right
            bitree[bitree[t_id].right].sibling = bitree[t_id].left
    else:
        leaves.add(t_id)

for t_id in range(n):
    if bitree[t_id].parent == nil:
        bitree[t_id].ntype = 'root'
        r = t_id
        break

set_depth(r, 0)

get_height(r)

for t_id in range(n):

    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
            t_id, bitree[t_id].parent, bitree[t_id].sibling, bitree[t_id].degree,
            bitree[t_id].depth, bitree[t_id].height, bitree[t_id].ntype))