How to get form fields in tab order using pdfbox?

Solution for How to get form fields in tab order using pdfbox?
is Given Below:

I have tried the getFields(), getFieldTree(), and the getFieldIterator() methods to get the fields in an PDAcroForm, but the order of the elements is always different from the tab order set up in the pdf file.
While I can iterate over these and set values of each field like this:

PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
Iterator<PDField> it = form.getFieldIterator();
while(it.hasNext()){
   PDField field = it.next();
   if(field.getName().equals("A")) field.setValue("...");
   if(field.getName().equals("B")) field.setValue("...");
   etc.
}

I was thinking it would be convenient to get the fields in tab order. Is there an efficient way to get the fields in tab order?