How does \Magento\Sales\Model\Order::getPayment() work?

https://github.com/magento/magento2/blob/ffea3cd/app/code/Magento/Sales/Model/Order.php#L875-L895

As you can see, if $this->getData(OrderInterface::PAYMENT); returns null then the method returns a random (the first due to the MySQL implementation) payment for an order, not the last payment.