You are given a rooted, ordered, but not necessarily binary, tree. Each node can be in one of two states: either "on" or "off."
Initially all nodes are off.
The rule is that you can switch a node on only if none of its descendants and none of its ancestors are already on.
The tree structure is fixed. Only the nodes' states may change.
The problem: devise an efficient data structure to support the following two operations. (You may need to do some preprocessing.)