As a famous sub-structure of Bayesian network, causal polytree is able to recover the causality very efficiently.
Here, I implement pearl's classical algorithm here for easy using. Details can be seen in Pearl's paper.
To recover general Causal polytree, one can download "Fisher's exact test" in my space for conditional independence test.
One can start from ControlCenter.m, I add a simple example there for better understanding.
If there is any question, just let me know, I will response to you as soon as possible.
 G. Rebane, J. Pearl, The recovery of causal poly-trees from statistical data, in: Proceedings of the Third Conference on Uncertainty Artificial Intelligence, Seattle, Washington, 1987, pp. 222–228