code: private static Node getXmlSignatureInsertLocation(final Element elem) {
          val nodeListExtensions = elem.getElementsByTagNameNS(SAMLConstants.SAML20P_NS, "Extensions");
          if (nodeListExtensions.getLength() != 0) {
              return nodeListExtensions.item(nodeListExtensions.getLength() - 1);
          }
          val nodeListStatus = elem.getElementsByTagNameNS(SAMLConstants.SAML20P_NS, "Status");
          return nodeListStatus.item(nodeListStatus.getLength() - 1);
      }
docs: Gets the xml signature insert location.
  
  @param elem the elem
  @return the xml signature insert location