def get_kvps(doc, keys):
    """
    Extracts one or more keys ('keys' can be a string or list of strings)
    from the dictionary 'doc'.

    Return a subset of 'doc' with only the 'keys' specified as members, all
    other data in the dictionary will be filtered out.
    Return an empty dict if no keys are found.
    """
    if not isinstance(keys, list):
        keys = [keys]

    new_doc = {}
    for key in keys:
        value = get_value(doc, key)
        if value is not None:
            nested = new_doc
            while "." in key:
                attr = key[: key.index(".")]
                if attr not in nested:
                    nested[attr] = {}
                nested = nested[attr]
                key = key[key.index(".") + 1 :]
            nested[key] = value

    return new_doc

    Extracts one or more keys ('keys' can be a string or list of strings)
    from the dictionary 'doc'.

    Return a subset of 'doc' with only the 'keys' specified as members, all
    other data in the dictionary will be filtered out.
    Return an empty dict if no keys are found.
    
st2client/st2client/utils/jsutil.py