PHEW: a parallel segmentation algorithm for three-dimensional AMR datasets - application to structure detection in self-gravitating flows