Handle empty merkle branches

Corrects the issue where calculating merkle root from an empty merkle branch results in
nil. Now correctly returns the original hash.