'Returns a FacetResult populated from search_service FacetResult pb.'

def _NewFacetResultFromPb(self, facet_result_pb):

    values = []
    for facet_value_pb in facet_result_pb.value_list():
        refinement_pb = facet_value_pb.refinement()
        if refinement_pb.has_range():
            range_pb = refinement_pb.range()
            facet_range = FacetRange(start=(float(range_pb.start()) if range_pb.has_start() else None), end=(float(range_pb.end()) if range_pb.has_end() else None))
        else:
            facet_range = None
        refinement = FacetRefinement(name=refinement_pb.name(), value=(refinement_pb.value() if refinement_pb.has_value() else None), facet_range=facet_range)
        values.append(FacetResultValue(label=facet_value_pb.name(), count=facet_value_pb.count(), refinement=refinement))
    return FacetResult(name=facet_result_pb.name(), values=values)
