A tree T will be called structured if for every d, all nodes at distance d from the root contain the same type of data.
Our goal is to construct a new tree T' which is the "intersection" of some subtrees of T.
That is, T' has the same structure (same data types at the same order) as T, and every node v in T' is the result of an agreement/intersection of corresponding nodes in T.
An example will show this best:
In the tree T below, each leaf represents a colored permutation of 2 elements.
Our goal is to find all possible colored permutations of 3 elements: that are both allowed permutations by the restrictions in T, and have the same color. For example, 231 is an allowed permutation but doesn't have a mutual color.
Well then, how should I construct T'? what data structure should I use?
My intuition says a BFS-style algorithm will get the job done nicely, yet I suspect a better logic could be applied.
For example, here is one idea I had and I am not sure how to proceed with: maybe I can store T in some fancy database, compute all allowed permutations together, and then call the corresponding colored leaves?
