Or maybe you need to set aside the shell scripting and start learning a different language? "Things like inverted trees, functional programming, [and] polymorphism" really have no analogue in a shell language. Start working in C++ or Java, for example, and I suspect these things will start making more sense.