public static @Nullable XmlTag getReferencedTag(XmlTag tag) {
    final String tagName = tag.getName();
    if (FxmlConstants.FX_REFERENCE.equals(tagName) || FxmlConstants.FX_COPY.equals(tagName)) {
      final XmlAttribute attribute = tag.getAttribute(FxmlConstants.SOURCE);
      if (attribute != null) {
        final XmlAttributeValue valueElement = attribute.getValueElement();
        if (valueElement != null) {
          final PsiReference reference = valueElement.getReference();
          if (reference != null) {
            final PsiElement resolve = reference.resolve();
            if (resolve instanceof XmlAttributeValue) {
              return PsiTreeUtil.getParentOfType(resolve, XmlTag.class);
            }
          }
        }
      }
    }
    return null;
  }
public static @Nullable XmlTag getReferencedTag(XmlTag tag)