It appears that what you're looking for in the first question is some logic that has the following truth table:
Fixed input, DesiredOutput (another "input"), Other input (actually, truth table output): 0,X,1 (or zero, but I have to choose 1) 1,1,1 1,0,0
Fixed input, DesiredOutput (another "input"), Other input (actually, truth table output):
0,X,1 (or zero, but I have to choose 1)
1,1,1
1,0,0
That logic could be built with some gates. You could extend this to more levels such as your second question.