code: def getattribute(model, item):
      
      elements = item.split('.')
      element = elements.pop(0)
      try:
          attr = getattr(model, element, None)
      except:
          return
      if attr is None:  # end of recursion
          return
      if callable(attr):
          try:
              attr = attr()
          except:  # couldn't call this method without params
              return
      if elements:
          return getattribute(attr, '.'.join(elements))
      return attr
docs: Chained lookup of item on model
  
      If item has dots (eg: 'foo.bar.baz'), recursively call getattribute():
      e = getattr(model, 'foo')
      e = getattr(e, 'bar')
      e = getattr(e, 'baz')
      At each step, check if e is a callable, and if so, use e()