def calculation(expression):
cal_exp = expression.split()
p_stack = Stack()
e_tree = BinaryTree('')
p_stack.push(e_tree)
current_tree = e_tree
for i in cal_exp:
if i == "(":
current_tree.insertLeft('')
p_stack.push(current_tree)
current_tree = current_tree.getLeftChild()
elif i not in ['+', '-', '*', '/', ')']:
current_tree.setRootVal(int(i))
parent = p_stack.pop()
current_tree = parent
elif i in ['+', '-', '*', '/']:
current_tree.setRootVal(i)
current_tree.insertRight('')
p_stack.push(current_tree)
current_tree = current_tree.getRightChild()
elif i == ')':
current_tree = p_stack.pop()
return evaluate(e_tree)