private void addLayoutOnlyNodeToLayoutOnlyNode(
      ReactShadowNode parent, ReactShadowNode child, int index) {
    ReactShadowNode parentParent = parent.getParent();

    // If the parent hasn't been attached to its parent yet, don't issue commands to the native
    // hierarchy. We'll do that when the parent node actually gets attached somewhere.
    if (parentParent == null) {
      return;
    }

    int transformedIndex = index + parentParent.getNativeOffsetForChild(parent);
    if (parentParent.isLayoutOnly()) {
      addLayoutOnlyNodeToLayoutOnlyNode(parentParent, child, transformedIndex);
    } else {
      addLayoutOnlyNodeToNonLayoutOnlyNode(parentParent, child, transformedIndex);
    }
  }
  private void addNodeToNode(ReactShadowNode parent, ReactShadowNode child, int index) {
    int indexInNativeChildren = parent.getNativeOffsetForChild(parent.getChildAt(index));
    boolean parentIsLayoutOnly = parent.isLayoutOnly();
    boolean childIsLayoutOnly = child.isLayoutOnly();

    // Switch on the four cases of:
    //   add (layout-only|not layout-only) to (layout-only|not layout-only)
    if (!parentIsLayoutOnly && !childIsLayoutOnly) {
      addNonLayoutNodeToNonLayoutNode(parent, child, indexInNativeChildren);
    } else if (!childIsLayoutOnly) {
      addNonLayoutOnlyNodeToLayoutOnlyNode(parent, child, indexInNativeChildren);
    } else if (!parentIsLayoutOnly) {
      addLayoutOnlyNodeToNonLayoutOnlyNode(parent, child, indexInNativeChildren);
    } else {
      addLayoutOnlyNodeToLayoutOnlyNode(parent, child, indexInNativeChildren);
    }
  }