from datetime import datetime

def convert_datetime_p(doc):
    if isinstance(doc, dict):
        for key, value in doc.items():
            if isinstance(value, datetime):
                doc[key] = value.isoformat()
            elif isinstance(value, dict) or isinstance(value, list):
                doc[key] = convert_datetime_p(value)
    elif isinstance(doc, list):
        for i in range(len(doc)):
            doc[i] = convert_datetime_p(doc[i])
    return doc
