private Expression FindChildSource(MappingBuilderNode child)
        {
            var node = child as AssigningNode;
            if (node != null)
                return node.Source;

            return FindChildSource(child.Children.First());
        }
        private static void CreateNodes(
            PathPart[] parts,
            Expression source,
            object converter,
            int index,
            Dictionary<string, MappingBuilderNode> nodeMap,
            MappingBuilderNode parentNode = null)
        {
            var part = parts[index];
            MappingBuilderNode currentNode;

            if (!nodeMap.TryGetValue(part.Path, out currentNode))
            {
                // Create node
                var currentNodes = CreateNode(
                    part.Member,
                    part.Indexer,
                    index == parts.Length - 1 ? source : null,
                    converter).ToArray();

                for (var i = 0; i < currentNodes.Length - 1; i++)
                    currentNodes[i].Children.Add(currentNodes[i + 1]);

                foreach (var c in currentNodes)
                    if (!nodeMap.ContainsKey(c.Path))
                        nodeMap.Add(c.Path, c);

                parentNode?.Children.Add(currentNodes.First());

                currentNode = currentNodes.Last();
            }

            if (index + 1 < parts.Length)
                CreateNodes(parts, source, converter, index + 1, nodeMap, currentNode);
        }
 private IEnumerable<Expression> FindSourceExpressionRecursive(MappingBuilderNode node)
 {
     var an = node as AssigningNode;
     if (an != null)
         yield return an.Source;
     else
         foreach (var ch in node.Children)
             foreach (var src in FindSourceExpressionRecursive(ch))
                 yield return src;
 }