Reduce Map And Filter Function Python Format String Binary Tree