Gets the index of a ExpandableWrapper within the helper item list based on
the index of the ExpandableWrapper.

@param parentPosition The index of the parent in the list of parents
@return The index of the parent in the merged list of children and parents
163490
@UiThread
    private int getFlatParentPosition(int parentPosition) {
        int parentCount = 0;
        int listItemCount = mFlatItemList.size();
        for (int i = 0; i < listItemCount; i++) {
            if (mFlatItemList.get(i).isParent()) {
                parentCount++;

                if (parentCount > parentPosition) {
                    return i;
                }
            }
        }

        return INVALID_FLAT_POSITION;
    }
459040
public final int childItemPosition(int childAdapterPosition) {
        int itemCount = 0;

        int parentCount = parentItemCount();
        for (int i = 0; i < parentCount; i++) {
            itemCount += 1;

            if (isExpanded(i)) {
                int childCount = childItemCount(i);
                itemCount += childCount;

                if (childAdapterPosition < itemCount) {
                    return childCount - (itemCount - childAdapterPosition);
                }
            } else {
                // itemCount += 1;
            }
        }

        throw new IllegalStateException("The adapter position is invalid: " + childAdapterPosition);
    }
238014
public Optional<SubMenuItem> getSubMenuById(int parentId) {
        return  getAllSubMenus().stream().filter(subMenu->subMenu.getId() == parentId).map(m->(SubMenuItem)m).findFirst();
    }
418136
private TreeNode getParentTreeNode(TreeNode child) {
        TreeNode parentTreeNode = parentIndex.get(child);

        if (parentTreeNode == null)
            return null;

        // Makes sure the parent node is still present in the tree
        else if (contains(parentTreeNode.getQueryNode()))
            return parentTreeNode;
        else
            throw new RuntimeException("Internal error: points to a parent that is not (anymore) in the tree");
    }
889971
public int getNodeIndex(NodeData parentData, InternalQName name, String skipIdentifier)
      throws PathNotFoundException, IllegalPathException, RepositoryException
   {

      if (name instanceof QPathEntry)
      {
         name = new InternalQName(name.getNamespace(), name.getName());
      }
      
      int newIndex = 1;

      NodeDefinitionData nodedef =
         nodeTypeDataManager.getChildNodeDefinition(name, parentData.getPrimaryTypeName(), parentData
            .getMixinTypeNames());


      List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, skipIdentifier);
      List<ItemState> transientDeletedChilds;

      if (nodedef.isAllowsSameNameSiblings())
      {
         transientDeletedChilds = getItemStatesList(parentData, name, ItemState.DELETED, null);
      }
      else
      {
         transientDeletedChilds = getItemStatesList(parentData, new QPathEntry(name, 0), ItemState.DELETED, null);
         ItemData sameNameNode = null;
         try
         {
            sameNameNode = dataConsumer.getItemData(parentData, new QPathEntry(name, 0), ItemType.NODE, false);
         }
         catch (PathNotFoundException e)
         {
            // Ok no same name node;
            return newIndex;
         }
         if (((sameNameNode != null) || (transientAddChilds.size() > 0)))
         {
            if ((sameNameNode != null) && (transientDeletedChilds.size() < 1))
            {
               throw new ItemExistsException("The node  already exists in " + sameNameNode.getQPath().getAsString()
                  + " and same name sibling is not allowed ");
            }
            else if (transientAddChilds.size() > 0)
            {
               throw new ItemExistsException("The node  already exists in add state "
                  + "  and same name sibling is not allowed ");

            }            
         }
      }

      newIndex += transientAddChilds.size();
      List<NodeData> existedChilds = dataConsumer.getChildNodesData(parentData);

      // Calculate SNS index for dest root
      main: for (int n = 0, l = existedChilds.size(); n < l; n++)
      {
         NodeData child = existedChilds.get(n);
         if (child.getQPath().getName().equals(name))
         {
            // skip deleted items
            if (!transientDeletedChilds.isEmpty())
            {
               for (int i = 0, length = transientDeletedChilds.size(); i < length; i++)
               {
                  ItemState state = transientDeletedChilds.get(i);
                  if (state.getData().equals(child))
                  {
                     transientDeletedChilds.remove(i);
                     continue main;
                  }
               }
            }
            newIndex++; // next sibling index            
         }
      }
      // searching
      return newIndex;
   }
254660
public com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory getParentDimensionValue() {
        return parentDimensionValue;
    }
552944
@Override
    public Node getParentNode(String parentNodeId)
    {
        NodeLink link = new NodeLink(parentNodeId, getNodeId());

        if (this.parents == null)
        {
            return null;
        }
        else
        {
            return this.parents.get(link);
        }
    }
718975
public Long getRelativePosition(Long position) {
		long relativePosition = 0L;
		for (Location location : locations) {
			if (location instanceof RemoteLocation) {
				relativePosition += location.getLength();
			} else {
				if (position < location.getBeginPosition()
						|| position > location.getEndPosition()) {
					relativePosition += location.getLength();
				} else {
					if (location.isComplement()) {
						relativePosition += (location.getEndPosition()
								- position + 1);
					} else {
						relativePosition += (position
								- location.getBeginPosition() + 1);
					}
					if (isComplement()) {
						relativePosition = getLength() - relativePosition + 1;
					}
					return relativePosition;
				}
			}
		}
		return null;
	}
182716
public static IParsedElement boundingParent( List<IParseTree> locations, int position, Class<? extends IParsedElement>... possibleTypes )
  {
    IParseTree location = IParseTree.Search.getDeepestLocation( locations, position, true );

    IParsedElement pe = null;
    if( location != null )
    {
      pe = location.getParsedElement();
      while( pe != null && !isOneOfTypes( pe, possibleTypes ) )
      {
        pe = pe.getParent();
      }
    }
    return pe;
  }
398905
public int getIndex() {
        if (parent != null) {
            for (int i = 0; i < parent.children.size(); i++) {
                if (parent.children.get(i) == this) {
                    return i;
                }
            }
        }
        
        return -1;
    }
652667
public Type getParentType()
    {
        Type ret = null;
        if (this.parentTypeId != null && this.parentTypeId != 0) {
            try {
                ret = Type.get(this.parentTypeId);
            } catch (final CacheReloadException e) {
                Type.LOG.error("Could not read parentType for id: {}", this.parentTypeId);
            }
        }
        return ret;
    }
173492
public CmsClientSitemapEntry getParentEntry(CmsClientSitemapEntry entry) {

        String path = entry.getSitePath();
        String parentPath = CmsResource.getParentFolder(path);
        if (parentPath == null) {
            return null;
        }
        return getEntry(parentPath);
    }
738468
public static List<Element> getAllChildElements(Element parent) {
        List<Element> result;
        NodeList nodes;
        int i;
        int max;
        Node node;

        result = new ArrayList<>();
        nodes = parent.getChildNodes();
        max = nodes.getLength();
        for (i = 0; i < max; i++) {
            node = nodes.item(i);
            if (node instanceof Element) {
                result.add((Element) node);
            }
        }
        return result;
    }
627373
private List<ExpandableWrapper<P, C>> generateFlattenedParentChildList(List<P> parentList) {
        List<ExpandableWrapper<P, C>> flatItemList = new ArrayList<>();

        int parentCount = parentList.size();
        for (int i = 0; i < parentCount; i++) {
            P parent = parentList.get(i);
            generateParentWrapper(flatItemList, parent, parent.isInitiallyExpanded());
        }

        return flatItemList;
    }
826281
function getSibling(node, relativeIndex) {
  var parent = node.parentNode;
  if (parent === null) {
    return null;
  }
  var currentIndex = parent.childNodes.indexOf(node);
  var siblingIndex = currentIndex + relativeIndex;
  if (siblingIndex < 0 || siblingIndex > parent.childNodes.length - 1) {
    return null;
  }
  return parent.childNodes[siblingIndex];
}
1363405
function getThingPosition(user, parentThing, childThing) {

	if (!childThing)
		throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Child Thing can't be null", 29);

	// If User is equal to null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing
	if (!user)
		return null;

	let userId = user._id;
	let parentThingId = parentThing ? parentThing._id : null;

	return childThing.parentsThingsIds.find(p => p.userId == userId && p.parentThingId == parentThingId);
}
445972
PropertyMap getPrimaryParent() {
    if (parentSource == null) {
      return null;
    }
    ObjectType iProto = parentSource.getImplicitPrototype();
    return iProto == null ? null : iProto.getPropertyMap();
  }