@Nullable
  private static PsiElement getOnlyChildFromDescriptor(EquivalenceDescriptor equivalenceDescriptor, NodeFilter filter) {
    if (!equivalenceDescriptor.getConstants().isEmpty()) {
      return null;
    }

    final List<SingleChildDescriptor> singleChildren = equivalenceDescriptor.getSingleChildDescriptors();
    final List<MultiChildDescriptor> multiChildren = equivalenceDescriptor.getMultiChildDescriptors();
    final List<PsiElement[]> codeBlocks = equivalenceDescriptor.getCodeBlocks();

    if (singleChildren.size() + multiChildren.size() + codeBlocks.size() != 1) {
      return null;
    }

    if (!singleChildren.isEmpty()) {
      final SingleChildDescriptor descriptor = singleChildren.get(0);
      final PsiElement child = descriptor.getElement();

      if (child != null) {
        final SingleChildDescriptor.MyType type = descriptor.getType();

        if (type == SingleChildDescriptor.MyType.DEFAULT) {
          return child;
        }
        else if (type == SingleChildDescriptor.MyType.CHILDREN ||
                 type == SingleChildDescriptor.MyType.CHILDREN_IN_ANY_ORDER) {
          return getOnlyChild(child, filter);
        }
      }
    }
    else if (!multiChildren.isEmpty()) {
      final MultiChildDescriptor descriptor = multiChildren.get(0);
      final PsiElement[] children = descriptor.getElements();

      if (children.length == 1 && descriptor.getType() != MultiChildDescriptor.MyType.OPTIONALLY) {
        return children[0];
      }
    }
    else if (!codeBlocks.isEmpty()) {
      final PsiElement[] codeBlock = codeBlocks.get(0);
      if (codeBlock != null && codeBlock.length == 1) {
        return codeBlock[0];
      }
    }
    return null;
  }
@Nullable
  private static PsiElement getOnlyChildFromDescriptor(EquivalenceDescriptor equivalenceDescriptor, NodeFilter filter)