Hierarchical Equations for Open System Dynamics in Fermionic and Bosonic Environments