Fix complexity of compute_root_causes

Closes #1252