Add flattening of tree search results