Taken algorithm from "UltimateParent" for pdoField
Version 1.7.0 beta1