canvas tree-search function