A simple implementation of a backtracking algorithm with a binary tree