Pseudo Code
function TREE-SEARCH(problem) returns a solution, or failure
initialize the frontier using the initial state of problem
loop do
if the frontier is empty then
return failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then
return the corresponding solution
expand the chosen node, adding the resulting nodes to the frontier