code: private Account findParent(Account parent, Account account) {
          if (parent == null || account == null)
              return null;
  
          // Does this parent contain the child account?
          if (parent.getChildren().contains(account))
              return parent;
  
          // Recurse through the children
          for (Account child : parent.getChildren()) {
              Account theOne = findParent(child, account);
              if (theOne != null)
                  return theOne;
          }
  
          return null;
      }
docs: Internal routine to locate a parent (recursive, don't loop your trees!).
  
  @param parent  The parent to start searching with.
  @param account The account to find the parent of.
  @return The parent account, else null if not found.