<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def annotateTree(bT, fn):
 """ annotate a tree in an external array using the given function """

    l = [None]*bT.traversalID.midEnd
    def fn2(bT):
        l[bT.traversalID.mid] = fn(bT)
        if bT.internal:
            fn2(bT.left)
            fn2(bT.right)
    fn2(bT)
    return l