def VarInTree(tree):
    """Return all variables in a tree (list)"""
    vars = list()
    if 'splitVar' in tree:
        vars += [tree['splitVar']]
        if 'left' in tree:
            vars += VarInTree(tree['left'])
        if 'right' in tree:
            vars += VarInTree(tree['right'])
    return vars