Given a binary tree, write an algorithm to traverse it and find specific nodes representing hierarchical UI elements.
Use def find_ui_nodes(tree, targets):. Represent each node as [value, left, right], with None for a missing child. Return every root-to-node path whose value appears in targets, in preorder traversal order. Include duplicate matching values when they occur at different nodes.
def find_ui_nodes(tree, targets):