Causal discovery with endogenous context variables