public class Factory {   public INode CreateNode(TypeEnum type)   {       switch(type)       {           case TypeEnum.Document:               return new DocumentNode(this);           case TypeEnum.Item:               return new ItemNode();       }   }}public interface INode{    void DoAction();}public class ItemNode : INode{    void DoAction()    {        // Nothing to do or simple action without more childs.    }}public class DocumentNode : INode{    private Factory factory;    public Node(Factory factory)    {        this.factory = factory;    }    public void DoAction()    {        var nodeTypes = this.GetNodeTypes();        foreach (var value in nodeTypes)        {              var node = this.factory.CreateObject(value);            node.DoAction(otherValues);        }    }    private IEnumerable<TypeEnum> GetNodeTypes()    {        // Retrieve values here... Could be DocumentNode or ItemNode types.    }}Is it a valid approach and makes sense to inject the factory used to create a class instance into the created instance itself to use it (as a tree)?
Factory injection into factory created object
patterns and practices;factory
Yes.  If an object needs to create another object of its own type (or of a related type if you have a factory that builds a family of types) then the most sensible solution to me seems to inject its factory at creation time.  In fact, I don't really see any alternative to this approach that doesn't lose the benefits of using factories entirely.