Here's the Python code to implement a process tree for a Purchase-to-Pay process in pm4py:

```python
from pm4py.objects.process_tree.obj import ProcessTree, Operator

# Define the root of the process tree (parallel execution of tasks)
root = ProcessTree(operator=Operator.PARALLEL)

# Purchase Order Creation
create_po = ProcessTree(label="Create Purchase Order", parent=root)

# Approval (sequence: Approval or Rejection)
approval = ProcessTree(operator=Operator.SEQUENCE, parent=root)
approve = ProcessTree(label="Approve Purchase Order", parent=approval)
reject = ProcessTree(label="Reject Purchase Order", parent=approval)
approval.children.append(approve)
approval.children.append(reject)

# Send Purchase Order (after creation)
send_po = ProcessTree(label="Send Purchase Order", parent=root)

# Receive Goods (after sending PO)
receive_goods = ProcessTree(label="Receive Goods", parent=root)

# Invoice Processing (loop until payment)
invoice_processing = ProcessTree(operator=Operator.LOOP, parent=root)
receive_invoice = ProcessTree(label="Receive Invoice", parent=invoice_processing)
process_invoice = ProcessTree(label="Process Invoice", parent=invoice_processing)
payment = ProcessTree(label="Make Payment", parent=invoice_processing)

# Define loop behavior (process invoice -> payment, then loop back)
invoice_processing.children.append(receive_invoice)
invoice_processing.children.append(process_invoice)
process_invoice.children.append(payment)

# Add all child nodes to the root
root.children.append(create_po)
root.children.append(approval)
root.children.append(send_po)
root.children.append(receive_goods)
root.children.append(invoice_processing)

# Print the process tree (optional)
# You can use libraries like pm4py.visualization.process_tree to visualize the tree
# print(root)
```

This code defines a process tree with the following structure:

1. **Parallel Tasks:**
    - Create Purchase Order
    - Approval (Approve or Reject)
2. **Sequential Tasks (after one branch of Approval):**
    - Send Purchase Order
    - Receive Goods
3. **Looping Task (until payment):**
    - Receive Invoice
    - Process Invoice
    - Make Payment

This is a simplified example, and you can customize it further to include additional activities specific to your Purchase-to-Pay process. Remember to set the parent node for each child process tree object.
