private void addNestedChildren(@NotNull PsiElement elem,
                                 @NotNull List<Block> list,
                                 @Nullable AlignmentProvider.Aligner aligner,
                                 final boolean topLevel,
                                 @NotNull Wrap wrap) {
    final List<ASTNode> children = visibleChildren(elem.getNode());
    List<ASTNode> nodes = flattenQualifiedReference(elem);
    if (nodes != null && !nodes.isEmpty()) {
      int i = 0;
      while (i < nodes.size()) {
        ASTNode node = nodes.get(i);
        if (TokenSets.DOTS.contains(node.getElementType())) break;
        i++;
      }
      if (i == nodes.size()) {
        list.add(new MethodCallWithoutQualifierBlock(wrap, topLevel, nodes, myContext));
        return;
      }

      if (i > 0) {
        processNestedChildrenPrefix(list, aligner, false, nodes.subList(0, i), wrap);
      }
      Indent indent = getContinuationWithoutFirstIndent();

      List<Block> childBlocks = new ArrayList<>();
      ASTNode dotNode = nodes.get(i);
      if (aligner != null) {
        aligner.append(dotNode.getPsi());
      }

      Wrap noneWrap = Wrap.createWrap(WrapType.NONE, false);

      boolean shouldWrapAfterDot = myContext.getGroovySettings().WRAP_CHAIN_CALLS_AFTER_DOT;
      Wrap identifierWrap = shouldWrapAfterDot ? wrap : noneWrap;
      Wrap dotWrap = shouldWrapAfterDot ? noneWrap : wrap;

      childBlocks.add(myContext.createBlock(dotNode, getIndent(dotNode), dotWrap));

      List<ASTNode> callNodes = nodes.subList(i + 1, nodes.size());
      if (!callNodes.isEmpty()) {
        childBlocks.add(new MethodCallWithoutQualifierBlock(identifierWrap, topLevel, callNodes, myContext));
      }

      SyntheticGroovyBlock synBlock = new SyntheticGroovyBlock(childBlocks, noneWrap, indent, indent, myContext);
      list.add(synBlock);

      return;
    }

    processNestedChildrenPrefix(list, aligner, topLevel, children, wrap);
  }
private void addNestedChildren(@NotNull PsiElement elem,
                                 @NotNull List<Block> list,
                                 @Nullable AlignmentProvider.Aligner aligner,
                                 final boolean topLevel,
                                 @NotNull Wrap wrap)