def _custom_target_list_to_child_list(custom_targets, is_operator):
    _children = defaultdict(lambda: defaultdict(list))
    for value in custom_targets:
        _children[value.parent_id][is_operator].append(value)

    dfp_children = []
    for _parent_id, _operations in _children.iteritems():
        for _operator, _values in _operations.iteritems():
            _value_target_ids = []
            _node_type = None
            _node_value_type = None

            for _custom_value in _values:
                _this_node_type = _custom_value.node_key
                _this_node_value_type = _custom_value.id_key

                if not _node_type and not _node_value_type:
                    _node_type = _this_node_type
                    _node_value_type = _this_node_value_type

                if (_this_node_type != _custom_value.node_key or
                        _this_node_value_type != _custom_value.id_key):
                    raise ParselmouthException(
                        "Could not serialize Custom Target: %s" % _custom_value
                    )
                _value_target_ids.append(_custom_value.id)

            _doc = {
                'operator': _operator,
                'xsi_type': _node_type,
                _node_value_type: _value_target_ids,
            }
            if _parent_id:
                _doc['keyId'] = _parent_id

            dfp_children.append(_doc)

    return dfp_children
Returns a dictionary containing metadata about the account.
dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py/_custom_target_list_to_child_list--crossover with--dataset/ETHPy150Open rackspace/pyrax/pyrax/object_storage.py/StorageClient.get_account_metadata