def METHOD_NAME(
    row: Row,
    query_paths: FieldPathNodeInput,
    delete_elements: bool = True,
) -> Dict[str, Any]:
    """
    Modifies row in place to remove unmatched array elements or unmatched embedded documents within arrays.
    :param row: Record retrieved from a dataset
    :param query_paths: FieldPaths mapped to a list of values you want to match.
    :param delete_elements: If True, *removes* unmatched indices from array. If False, just *replaces* the data,
    so the original indices are preserved.
    :return: A modified record with array elements potentially eliminated if array data was targeted by a query path
    :Example:
    The given row was retrieved from a dataset because an element in row["A"] matched 2 or an element in
    row["C"]["D"] matched 5.  row["A"] is filtered to just contain the matching element, and row["C"] is filtered
    to just contain the objects where "D" = 5. Non-array elements should not be touched.
    filter_element_match(
        row={"A": [1, 2, 3], "B": 2, "C": [{"D": 3, "E": 4}, {"D": 5, "E": 6}, {"D": 5, "E": 7}]},
        query_paths={FieldPath("A"): [2], FieldPath("C, "D"): [5]}
    )
    {"A": [2], "B": 2, "C": [{"D": 5, "E": 6}, {"D": 5, "E": 7}]}
    :Example:
    With delete_elements=False, we replace elements with placeholder text instead.
    filter_element_match(
        row={"A": [1, 2, 3], "B": 2, "C": [{"D": 3, "E": 4}, {"D": 5, "E": 6}, {"D": 5, "E": 7}]},
        query_paths={FieldPath("A"): [2], FieldPath("C, "D"): [5]},
        delete_elements=False
    )
    {
     'A': ['FIDESOPS_DO_NOT_MASK', 2, 'FIDESOPS_DO_NOT_MASK'],
     'B': 2,
     'C': ['FIDESOPS_DO_NOT_MASK', {'D': 5, 'E': 6}, {'D': 5, 'E': 7}]
    }
    """
    detailed_target_paths: List[DetailedPath] = build_refined_target_paths(
        row, query_paths
    )
    array_paths_to_preserve: Dict[str, List[int]] = _expand_array_paths_to_preserve(
        detailed_target_paths
    )
    return _remove_paths_from_row(row, array_paths_to_preserve, delete_elements)